I try to keep data from à json file with cross domain. So i use jsonp but the file have the extension .js, so when i try $.ajax with dataType : ‘jsonp’ i have an error in console:
Uncaught SyntaxError: Unexpected token
The file is interpret as a javascript file an the request fail. Have you an idea for get data whithout this error.
$.ajax({
url : 'http://domaine.com/file.js',
contentType: "application/json; charset=utf-8",
dataType : 'jsonp',
success : function(data){
console.log(data);
// no enter in this callback
},
complete: function(data1, data2, data3){
// no data from file.js
}
});
I found file.js when i inspect page in scripts who are load an i can see all information, but with an error because it is considerate as javascript file.
Thanks for your help.
Convert your json to proper jsonp
Then request it with the given callback:
You could of course do it with jQuery too: