违反了相同的原产地政策?

嘿,
我正在使用jQuery AJAX Call从自托管的Web服务(同一个域)中提取数据,但它总是返回0,这表示存在跨域问题。 但这应该不是问题。

有任何建议如何解决这个问题? 谢谢!

网站运行我的脚本

http://www.mysite.com/facebook/el_login 

我的AJAX电话:

 var data = 'username=' + username.val() + '&password=' + password.val() $.ajax({ url: "http://www.mysite.com/api/v01/account/exists.json", type: "GET", data: data, cache: false, complete: function(transport) { if(transport.status == 200) { alert('Success'); } else { alert('Failed ' + transport.status ); } } }); }) 

Firebug请求标题:

 Request Headersview source Host www.mysite.com User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 Accept */* Accept-Language en-us,en;q=0.5 Accept-Encoding gzip,deflate Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive 115 Proxy-Connection keep-alive Content-Type application/x-www-form-urlencoded X-Requested-With XMLHttpRequest Referer http://www.mysite.com/facebook/el_login Cookie sessionid=xxx 

编辑:

好的,似乎静态站点(同一服务器)上的AJAX调用正在运行。 我的Webservice后端基于Django,Apache2和mod_wsgi ……也许这就是为什么失败的原因。

对于debuggin我使用:

 function showResponse(responseText, statusText, xhr, $form) { debugger; // TODO: Remove in production. } 

并在ajax调用中使用

 error: showResponse 

您是否尝试过使用以下参数:

  dataType: "json", contentType: "application/json; charset=utf-8", 

好吧,经过几个小时的星际争霸2计算出来之后。
我连接了提交按钮

 $('#submit').click(function () 

这似乎与jQuery Ajax产生了一些问题

解:
使用“旧”样式连接您的ajax呼叫。

  

 function sendLogin() { var query_data = { username: 'test', password: 'test'}; $.ajax({ url: "http://www.mysite.com/api/v01/account/exists.json", type: "POST", data: $.toJSON(query_data), dataType: 'application/json', contentType: 'application/json', complete: function(transport) { if(transport.status == 200) { alert('Success'); } else { alert('Failed ' + transport.status ); } } }); }