Hi jochk12345,
Please refer below sample. Set async is true then simultaneously call ajax multiple.
HTML
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
function Show() {
$.ajax({
type: "POST",
url: "CS.aspx/GetUserName",
data: '{name: "' + $("#<%=txtUserName.ClientID%>")[0].value + '" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
traditional: true,
async: true,
success: function OnSuccess(response) {
alert(response.d);
},
failure: function (response) {
alert(response.d);
}
});
$.ajax({
type: "POST",
url: "CS.aspx/GetPassword",
data: '{password: "' + $("#<%=txtPassword.ClientID%>")[0].value + '" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
traditional: true,
async: true,
success: function OnSuccess(response) {
alert(response.d);
},
failure: function (response) {
alert(response.d);
}
});
$.ajax({
type: "POST",
url: "CS.aspx/GetAddress",
data: '{location: "' + $("#<%=txtLocation.ClientID%>")[0].value + '" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
traditional: true,
async: true,
success: function OnSuccess(response) {
alert(response.d);
},
failure: function (response) {
alert(response.d);
}
});
}
</script>
<div>
Your Name :
<asp:TextBox ID="txtUserName" runat="server"></asp:TextBox>
Password :
<asp:TextBox ID="txtPassword" runat="server" TextMode="Password"></asp:TextBox>
Location :
<asp:TextBox ID="txtLocation" runat="server"></asp:TextBox>
<input id="btnGetTime" type="button" value="Show Details" onclick="Show()" />
</div>
Code
C#
[System.Web.Services.WebMethod]
public static string GetUserName(string name)
{
return "Hello name is : " + name;
}
[System.Web.Services.WebMethod]
public static string GetPassword(string password)
{
return "Hello password is :" + password;
}
[System.Web.Services.WebMethod]
public static string GetAddress(string location)
{
return "Hello location is :" + location;
}
VB.Net
<System.Web.Services.WebMethod()>
Public Shared Function GetUserName(ByVal name As String) As String
Return "Hello name is : " & name
End Function
<System.Web.Services.WebMethod()>
Public Shared Function GetPassword(ByVal password As String) As String
Return "Hello password is :" & password
End Function
<System.Web.Services.WebMethod()>
Public Shared Function GetAddress(ByVal location As String) As String
Return "Hello location is :" & location
End Function
Screenshot