How can I prevent a cross domain jQuery getJSON request from encoding the callback question mark:
$.getJSON(searchResultsURL, {
token: jSONAPItoken,
callback: '?'
}, function(data){
……
})
Ends up sending a request:
http://example.com/xxx?token=tokenxxx&callback=%3F
Where is it encoding the ? to %3f. How can I prevent this?
You’re mis-using
getJSON.$.getJSONrequires that thecallbackparameter be in the URL, not thedataargument.You need to add
?callback=?to the URL string; jQuery will then replace the?with an auto-generated callback function name.