[英]JQuery AJAX Post request doesn't work in IE or FF - Works fine in Chrome
No idea what's going on here. 不知道这是怎么回事。 Had some friends test a chat I was working on to find out that it only works in Chrome so far.
如果有一些朋友测试了我正在进行的聊天,以发现该聊天目前仅适用于Chrome。
The AJAX POST Request doesn't seem to be functioning. AJAX POST请求似乎没有运行。 In Chrome, I get the success callback.
在Chrome中,我收到了成功回调。 In IE or Firefox get no callbacks period.
在IE或Firefox中没有回调期。
You'll see I have the POST shortcut commented out. 您会看到我的POST快捷方式已被注释掉。 I was using it but it wasn't working so I switched to ajax for the debugging.
我正在使用它,但是没有用,所以我切换到ajax进行调试。 I also included the code around it just to make sure it's not the cause also.
我还围绕它添加了代码,以确保它也不是原因。
$(document).ready(function() {
$("#chatWindow").animate({ scrollTop: $("#chatWindow").height()}, 'normal');
$("#submitForm").submit(function() {
event.preventDefault();
var clientMessage = $("#messageText").val();
//$.post("chatProcess.php", {text: clientMessage});
$.ajax({
type: "POST",
url: "chatProcess.php",
data: {text: clientMessage},
dataType: "text",
error: function(){alert('Error!')},
success: function(){alert('Success!')}
});
$("#messageText").attr("value", "").focus();
return false;
});
});
Remove event.preventDefault();
删除
event.preventDefault();
or pass the event object as a parameter for your submit function. 或将事件对象作为您的Submit函数的参数传递。 Since you already have
return false;
由于您已经
return false;
, I would just remove event.preventDefault();
,我只删除
event.preventDefault();
. 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.