简体   繁体   English

使用$ .getJson()函数的响应为空

[英]Null response using $.getJson() function

I have been trying to get a response from a server sending a GET URL, but isn't working for this particular server, on the other hand, when I put the same GET URL in the browser I obtain an answer. 我一直试图从发送GET URL的服务器获取响应,但是不适用于该特定服务器,另一方面,当我将相同的GET URL放入浏览器时,我得到了答案。 The server is in django python and I don't have access, because I'm currently programming the client side. 服务器在django python中,我没有访问权限,因为我当前正在对客户端进行编程。

This is the javascript code: 这是javascript代码:

var url = "https://www.mysite.com/module/get_requ/?user=ms&money_type=F&coin-count=1&pass=test&slots_id=12&line-value=9&slots_type=12&cacheBuster=1278933269465&coin-value=0.05";  
$.getJSON(url,  
        function(data){  
            alert(data);  
        });  

but when i do: 但是当我这样做时:

var url = "http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=jso&jsoncallback=?";

In the above code it work perfect. 在上面的代码中,它工作完美。 So, I want to know if i'm doing something wrong, or the problem is in the server side. 因此,我想知道我是在做错什么,还是问题出在服务器端。

This is most likely because of same origin policy . 这很可能是由于相同的原产地政策 The flicker api uses JSONP, which is not subject to the SOP. 闪烁的api使用不受SOP约束的JSONP。 So, unless bingocastle.co.uk also exposes a JSONP interface, you will not be able to request data from bingocastle.co.uk client side, without going through some server proxy. 因此,除非bingocastle.co.uk也公开JSONP接口,否则您将无法从bingocastle.co.uk客户端请求数据,而无需通过某些服务器代理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM