Click here to Skip to main content
15,901,283 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello everybody, i have one function in webservice
i want to call them by javascript, could you tell me how do i
thank
Posted

Use AJAX extensions for the same.

Have a look at this article: Client-Side Web Service Calls with AJAX Extensions[^]
 
Share this answer
 
You can jQuery to make web service call from client side.


$(document).ready(function(){

$.ajax({
type: "POST",
url: "service.asmx/HelloWorld",
data: parameters,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
$("#message").html(msg.d);
}
});

});
 
Share this answer
 
v3
// Javascript function
function GetPatientDetails(val)
{

var id = $get(val);
/* Calling Page Method */
PageMethods.GetFunction(id,OnSuccess,OnFailure);
function OnSuccess(result)
{
if(result!='')
{
var resultArray=result.split('|');
}
}
function OnFailure(error)
{
alert('Error In Fetching');
}
}
//.cs file(Code Behind)

[WebMethod]
public static string GetFunction(string _id)
{

string result = ""
//User Code here

return result;
}

/NOTE : In Script manager set attribute EnablePageMethods="true"
//ASPX FORM

<asp:textbox id="txtPatientName" width="200px" onblur="GetPatientDetails();" xmlns:asp="#unknown">
runat="server">
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900