Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 通过localhost(路径)修复我在web中的访问权限的任何帮助。它通过IP工作,但不通过本地主机工作_Php_Jquery_Laravel - Fatal编程技术网

Php 通过localhost(路径)修复我在web中的访问权限的任何帮助。它通过IP工作,但不通过本地主机工作

Php 通过localhost(路径)修复我在web中的访问权限的任何帮助。它通过IP工作,但不通过本地主机工作,php,jquery,laravel,Php,Jquery,Laravel,根据我遇到的问题,当我创建聊天室并输入发送消息的代码时,我发布如下数据: function sendMessage() { var text = $('#text').val(); if (text.length > 0) { $.post('http://localhost/chats/public/sendMessage', {text: text, username: username}, function() {

根据我遇到的问题,当我创建聊天室并输入发送消息的代码时,我发布如下数据:

function sendMessage()
{
    var text = $('#text').val();

    if (text.length > 0)
    {
        $.post('http://localhost/chats/public/sendMessage', {text: text, username: username}, function()
        {
            $('#chat-window').append('<br><div style="text-align: right">'+text+'</div><br>');
            $('#text').val('');
            notTyping();
        });
    } 
函数sendMessage()
{
var text=$('#text').val();
如果(text.length>0)
{
$.post($)http://localhost/chats/public/sendMessage“,{text:text,username:username},函数()
{
$(“#聊天窗口”).append(“
”+text+”
”); $('#text').val(''); notTyping(); }); }

我认为问题在于按路径发布数据。

如果Javascript在同一个域上运行,您可以简单地避免将域放入请求

$.post('/chats/public/sendMessage', {text: text, username: username}, function()
{
    $('#chat-window').append('<br><div style="text-align: right">'+text+'</div><br>');
    $('#text').val('');
    notTyping();
});
$.post('/chats/public/sendMessage',{text:text,username:username},function()
{
$(“#聊天窗口”).append(“
”+text+”
”); $('#text').val(''); notTyping(); });
您使用的是哪种操作系统?windows?
if (text.length > 0)
    {
        $.post('<?php echo URL::asset("chats/public/sendMessage");?>', {text: text, username: username}, function()
        {
            $('#chat-window').append('<br><div style="text-align: right">'+text+'</div><br>');
            $('#text').val('');
            notTyping();
        });
    } 
<?php echo URL::asset("/chats/public/sendMessage");?>
'URL' => Illuminate\Support\Facades\URL::class,