Reputation: 181
I am trying to implement jsonp with jQuery but it is not working I did see the example in jsonp with jquery
But in my case it is always making ajax call I am appending &callback=?
at the end
I construct relative url like
var url="/pbs/getTraits.do"+ $('#pbstraits').serialize()+"&callback=?";
$.getJSON(url, null, function(data){
document.getElementById("msg").innerHTML = data.message;
});
is this the right way of doing it?
Also when I am sending query parameters along with url I have to encode which is the best way to do it.
Upvotes: 0
Views: 165
Reputation: 887255
jQuery looks for =?
in the querystring.
Your URL doesn't have a querystring. (it has no ?
)
Instead, you should write
$.getJSON("/pbs/getTraits.do?callback=?"", $('#pbstraits').serialize(), ...);
Upvotes: 1