Hi ,
Is it possible to call a webservice method through AJAX.?
If possible how can i do this?
Thanks!
Hi guy
It is possible
try with this functions
function getHTTPObject() {
var xmlhttp;
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
return xmlhttp;
}
function ajaxfunction(parameter) {
var url = "../nameof the webservice file/name of the web method";
var functionname = function processimageId() {
if (http.readyState == readystateno) {
if (http.status == httpstatus) {
var exist = http.responseXML.getElementsByTagName('int')[0].childNodes[0].nodeValue;
// the output of teh webservice return to the variable exist
if( exist == 'something'){
} else {
//do something
}
}
}
}
http = getHTTPObject();
http.onreadystatechange = functionname
http.open("POST", url, true);
http.setRequestHeader("Content-Type", "type of the content")
http.send("parameter=" + escape(parameter));
}
call this ajaxfunction where ever you want.