Error recieved (Chrome): Uncaught SyntaxError: Unexpected token :
Script, call:
var frypeurl = 'http://www.draugiem.lv/say/ext/like_count.php';
$.ajax({
url : frypeurl,
dataType : 'jsonp',
crossDomain : true,
data : { url : 'http://example.com/' },
headers : { 'Accept' : 'application/json', 'X-Request' : 'JSON' },
success : function(json){
console.log(json);
$('#frypecount').text(json.count);
}
});
When it's accessed from browser, it returns normal result, se开发者_Python百科e here. ({"count":"0"}
)
Have no idea what is causing it, tried it before with simply $.getJSON();
, but returns same error, hence the headers
, crossDomain
parameters.
What could be the problem?
One thing I'd like to add, that's the biggest social network here in Latvia, and they have a weird API, functioning wise and coding too, probably. So I still have a guess that it's a problem on their side. I've messaged them, but no response yet.
There is nothing weird. You need to pass callback function by the query string
$.getJSON(frypeurl+"?callback=?", {
url: "http://example.com/"
}, function(json){
console.log(json);
$("#frypecount").text(json.count);
});
精彩评论