Trying to access my json using $.getJson function of jquery
I am trying to access token from http://localhost:8090/appp/appp/getToken it returns me string with Content-Type:application/json on browse开发者_如何学JAVAr
I try to load this token using $.getJson from my wordpress application uploaded on url
http://localhost/wordpress/
but it does not return me that token
my code :
$.getJSON("http://localhost:8090/appp/appp/getToken",
{
format: "json"
},
function(token) {
alert(token);
});
Please help me
You will need to use jsonp since the domain is different from your page (due to the port number). The xhr request is considered cross domain and is falling foul of the same origin policy.
See the Additional Notes section from the jquery getJson docs
Additional Notes: Due to browser security restrictions, most "Ajax" requests are subject to the same origin policy; the request can not successfully retrieve data from a different domain, subdomain, or protocol. Script and JSONP requests are not subject to the same origin policy restrictions.
精彩评论