ajax post request treated differently on IE and Chrome
1 2 3 4 5 6 7 8 9 10 11 12 13 | $("#submitbutton").button().click(function() { var request = $.ajax({ type:"post", url:"mmm.php", data:"abc=abcdefghijklmnopqrstuvwxyz", success:function(data){ alert("success:" +data); }, error:function(data){ alert("error"+data); }, statusCode:{ 200:function(){alert("200");}, 304:function(){alert("304");}, 404:function(){alert("404");}}, isModified:function(){alert("Something was modified");} }); |
此IE9上的帖子已正确答复。在chrome上,它将生成带有以下内容的错误警报:"错误[Object] [Object]"
Chrome控制台未显示错误,服务器回复:
IE的
:
10.0.0.4 - - [22/Jul/2012:18:00:22 +0300]"GET /development-bundle/ui/jquery.ui.button.js HTTP/1.1" 200 11342"http://xxxx.xxxx.net/first.html""Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)"
对于Chrome:
10.0.0.4 - - [22/Jul/2012:18:08:34 +0300]"GET /development-bundle/ui/jquery.ui.button.js HTTP/1.1" 304 -"http://xxxx.xxxxxx.net/first.html?""Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536.11"
有人知道为什么chrome在" first.html"之后添加了问号,而IE却没有吗?这会导致apache服务器返回304,Chrome浏览器将其视为错误
谢谢
您首先要修复要传递给服务器的jSon。当前不正确。将其更改为以下内容,然后尝试。
1 2 3 4 5 6 7 8 9 10 11 12 13 | $("#submitbutton").click(function() { var request = $.ajax({ type:"post", url:"mmm.php", data:{abc:"abcdefghijklmnopqrstuvwxyz"}, success:function(data){ alert("success:" +data); }, error:function(data){ alert("error"+data); }, statusCode:{ 200:function(){alert("200");}, 304:function(){alert("304");}, 404:function(){alert("404");}}, isModified:function(){alert("Something was modified");} }); |
我还修改了您的事件绑定,