I have ajax request to post data to asmx webservice, how will i post multiple data values as json data to that url
$.ajax(
{
type:"POST",
url:"AjaxService.asmx/CheckUserNameAvailability",
data:"{\"userName\":\"" + userName + "\"}",
dataType:"json",
contentType:"application/json",
success: function(response)
{
if(response.d == true)
{
$("#display").text("username is available and updated to database");
$("#display").css("background-color","lightgreen");
}
else
{
$("#display").text("username is already taken");
$("#display").css("background-color","red");
}
}
});
This is the particular webservice code where i retrieve the username ,how can i retrieve many values passed from that paticular url ,for example i have to retrieve username ,password, email,phoneno etc...
public class AjaxService : System.Web.Services.WebService
{
[WebMethod]
public bool CheckUserNameAvailability(string userName)
{
List<String> userNames = new List<string>() { "azamsharp", "johndoe", "marykate", "alexlowe", "scottgu" };
var user = (from u in userNames
where u.ToLower().Equals(userName.ToLower())
select u).SingleOrDefault<String>();
return String.IsNullOrEmpty(user) ? true : false;
}
}
}