简体   繁体   English

jQuery AJAX发布请求不适用于IE或FF-在Chrome中正常运行

[英]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.

相关问题 jQuery在FF或IE中不起作用,但在Chrome中可以正常工作 - jQuery doesn't work in FF or IE but works fine in Chrome jQuery ajax发布在IE,FF,Chrome中正常运行,但在Safari中无法正常运行 - jquery ajax post works fine in IE, FF, Chrome but not Safari 在IE 9之前无法使用的Javascript / jquery代码在FF,Chrome,Safari中正常运行 - Javascript/jquery code that doesn't work prior to IE 9. Works fine in FF, Chrome, Safari jQuery $ .ajax请求可在IE中使用,但不适用于FF和Chrome - JQuery $.ajax Request works in IE but not FF and Chrome 简单的JQuery在Chrome中不起作用,FF在IE6上有效 - Simple JQuery doesn't work in Chrome ,FF works on IE6 jQuery.ajax类型:发布到IE中未初始化的ashx文件。 在FF,Chrome和Safari中正常运行 - jQuery.ajax type: Post to an ashx file not being initiated in IE. works fine in FF, Chrome, and Safari jQuery加载不适用于IE 9(在FF,Chrome和Safari上正常运行) - jQuery load does not work on IE 9 ( works fine on FF, Chrome and Safari) <a href doesn't fire after .Click jquery function call in IE. Works fine with Chrome and FF - <a href doesn't fire after .Click jquery function call in IE. Works fine with Chrome and FF jQuery scrollTop不会在FF或IE中创建动画,但在chrome中可以正常工作 - jQuery scrollTop doesn't animate in FF or IE but working fine in chrome iframe中生成的jQuery代码在IE中不起作用,但在FF和Chrome中有效 - Generated jQuery code in iframe doesn't work in IE but works in FF and Chrome
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM