jQuery Ajax – 无法获得响应

我正在使用这个jQuery.ajax:

var url = "http://client.my_url.com/test_get_account_data.php"; jQuery.ajax({ type: "GET", url: url, cache: false, success: function(resultsData){ alert("We're finally making the call."); }, error:function (jqXHR, textStatus, errorThrown){ alert("Error:" + textStatus+ "," + errorThrown); } }); 

要点击这个PHP脚本:

 "Level 3.accountName","type"=>"Level 3","name"=>"accountName","total"=>"1059.25","in"=>"8603.56","out"=>"7544.31"); $encodedResponse = json_encode($accountJSON); fwrite($fh, "We're at the end of get_account_data with encodedResponse:\n"); fwrite($fh, $encodedResponse."\n"); echo $encodedResponse; ?> 

但出于某种原因,我从未获得成功。 我已经尽可能地简化了这个,但它仍然失败了。 在日志中,我有输出:

 We're at the end of get_account_data with encodedResponse:
{"id":"Level 3.accountName", "type":"Level 3", "name":"accountName", "total":"1059.25", "in":"8603.56", "out":"7544.31"}

有没有人有什么建议? 我认为这将是非常容易的……也许它是,我只是在做一些愚蠢的事情。

谢谢

您似乎试图通过http://localhost:8080 AJAX GET请求调用http://client.my_url.com

根据浏览器的原始策略 ,您无法将AJAX GET / POST请求发送到另一个域。 您需要将JSONP用于跨域AJAX。