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,