Consider:
var resturl = "http://example.com";
cj.getJSON(
resturl + "&callback=?",
function(data)
{
console.log(data);
}
);
My callback function is never called. Why?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Two things here:
First, your URL addition should be
"?callback=?"since there’s no other querystring, or use the full$.ajax()call with ajsonpdata type, so it adds the querystring as needed, like this:Second, the domain you’re going to has to support JSONP.