Hi all,
My web method in my web service successfully retrieved the total row count from a database. If the return value is zero the variable "is_unique" is set to "true" else if the return value is 1 or more, it is set to "false". Then the variable "is_unique" is returned. The following are my code snippets.
//--------------- Web Service Code Snippet
[WebMethod]
public string function GetTotal(string firstname, string lastname)
{
if(firstname.length==0){return"Please enter first name";};
if(lastname.length==0){return"Please enter last name";};
string is_unique = "false";
//---- ADO.NET Code goes here
//---- More ADO.Net code
//---- More ADO.NET code
//---- More ADO.NET code
//---- More ADO.NET code
con.Open();
cmd.ExecuteNonQuery();
int count = Convert.ToInt32(outputParam.Value);
if (count == 0) { is_unique = "true"; }
else if(count>=1) { is_unique = "false"; }
con.Close();
return is_unique;
}
//--------------AJAX function on the frontend
function IsUnique() {
var jdata = {firstname: "Test", lastname: "Test"};$.ajax({
url: "http://localhost:21577/MyService.asmx/GetTotal",
data:jdata,
method: "Post",
dataType: "xml",
success: function (data) {
alert(data.value);
}
});
}The problem I am having is that when I try to retrieve data from the web service in the AJAX call on the frontend using "data.value", I get "Undefined". Please help me resolve this problem.