How to call a webservice method from an html page [javascript] with out refresh the page
Use jQuery for performin POST or GET request from your html page like this :
function fun()
{
var data="hello";
$.get("http://localhost/ws/service.asmx/HelloWord", function(response) {
data = response;
}).error(function(){
alert("Sorry could not proceed");
});
return data;
}
OR :
function fun()
{
var data="hello";
$.post('http://localhost/ws/service.asmx/HelloWord',{},function(response)
{ data = response;
}).error(function(){
alert("Sorry could not proceed");
});
return data;
}
You can send ajax request to a webservice
$.ajax({
url: "WebServiceURL",
data: "", //ur data to be sent to server
contentType: "application/json; charset=utf-8",
type: "GET",
success: function (data) {
alert(data);
},
error: function (x, y, z) {
alert(x.responseText +" " +x.status);
}
});