2012-10-05 28 views
1

我正在使用jQuery 1.8.2通过jQuery的ajax POST调用某些后端服务器API。后端服务器和网页都在同一个域中。jQuery.post被发送为IE9上的HTTP GET

在我的js文件,我只是要求$.post('/createAccount',data,function(e) { alert(e); });

在提琴手,该请求被发送一个GET,在IE9。

GET http://[redacted]/createAccount HTTP/1.1 
Accept: */* 
Origin: [redacted] 
Accept-Language: en-US 
Accept-Encoding: gzip, deflate 
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0) 
Host: [redacted] 
Connection: Keep-Alive 
Pragma: no-cache 

使用Chrome相同的页面(最新)返回提琴手如下:

POST http://[redacted]/createAccount HTTP/1.1 
Host: [redacted] 
Connection: keep-alive 
Content-Length: 103 
Origin: http://[redacted] 
X-Requested-With: XMLHttpRequest 
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.79 Safari/537.4 
Content-Type: application/x-www-form-urlencoded; charset=UTF-8 
Accept: */* 
Referer: http://[redacted]/builder?token=[redacted] 
Accept-Encoding: gzip,deflate,sdch 
Accept-Language: en-US,en;q=0.8 
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 

email=test123&token=[redacted]&company=tokentest1 

下面是使用$阿贾克斯,而不是$。员额(同一个问题)代码:

 $.ajax({ 
      url : '/createAccount', 
      type : 'POST', 
      data : obj, 
      dataType : 'json', 
      cache: 'false', 
      success : function(data) { 
       if(data.status === 'ok') { 

       } else { 
        alert('error'); 
       } 
      } 
     }); 
+0

对于调试,你可以切换到使用$ .ajax并比较结果吗? –

+0

我可以(实际上最初的调用是$ .ajax({...,type:'POST'})。调试有什么特别的好处吗? – Alan

+0

好吧,由于$ .post转发给$ .ajax,它消除了$ .post as the cause。 –

回答

0

这是一个清晰的时刻。我还有一些代码可以回退到MSFT的XDomainRequest,并且在那个代码中它强制所有请求得到,而不是从jQ​​uery选项对象中取出请求类型。

相关问题