I need to make an ajax post to a .NET web service on another domain. Can I set any return data coming from the server to jsonp and use js to read the data? I've come across this solution when posting to a .NET service:
http://encosia.com/using-jquery-to-directly-call-aspnet-ajax-page-methods/
$.ajax({
type: "POST",
url: "PageName.aspx/MethodName",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
// Do something interesting here.
}
});
I've used this before with much success, however my calls have always been within the same domain. Now that I would like to post cross-domain (is that even possible?), can the data that is returned be in jsonp to avoid any cross-domain issues.
Usually when I make GET requests cross-domain to let's say an API, I usually use "script" as my dataType in the ajax call and parse through the data with the callback function outside of the success ajax function.
Is it possible to use "script" as a dataType in the call above or how would I go about making this call and still treating the returned data as JSONP to be read inside of a callback function?