$.ajax({
type : "GET",
dataType : "jsonp",
url : '/',
data : {}
success: function(obj){
}
});
How can i use $.ajax dataType: jsonp cross-domain to post data?
$.ajax({
type : "GET",
dataType : "jsonp",
url : '/',
data : {}
success: function(obj){
}
});
How can i use $.ajax dataType: jsonp cross-domain to post data?
It's not possible with simple jsonp. Read this
To answer your question instead of sending you to another link like above:
The JS:
The PHP could possibly look like this:
Setting the
dataType
tojsonp
will allow jQuery to automatically add an extra?callback=?
to the end of yoururl
to specify the callback. If you specify your own like above it will use thecallback
name you are passing. If you need to specify a json callback name use thejsonpCallback
property. Or you can add as a param to the data property. If you need more info, please visit the jQuery API Ajax: http://api.jquery.com/jQuery.ajax/.Don't forget to add the
;
on the result string.I hope this helps!