Hi everyone. We all know the role of ajax and its implementation. We can use ajax in asp.net as well as in javascript/jquery. But there is a
Editorial Note
This articles was originally at wiki.asp.net but has now been given a new home on CodeProject. Editing rights for this article has been set at Bronze or above, so please go in and edit and update this article to keep it fresh and relevant.
$(document).ready(function() {
var surl = "http://www.anotherdomain.com/webservice.asmx";
$.ajax({
type: 'GET',
url: surl,
crossDomain: true,
contentType: "application/json; charset=utf-8",
data: { UserID: 1234 },
dataType: "jsonp",
success: function(msg) {
$.each(msg, function(name, value) {
alert(value);
});
},
error: function(xhr, status, error) { alert('Servidor de error 404 !!'); },
async: false,
cache: false
});
});
Note:- This will only work with json data type, so while requesting a web service should return the data in Javascript Object notation format.