Hello everyone,
I'm fairly new in web services and there's a problem that I ran into last night.
I have two methods in my web service Service.asmx FormSubmit() and Login(). My question is, i'm able to access my FormSubmit method but not able to access my Login method through AJAX.
This is my web method:
[WebMethod]
public void LoginOnClick(agentLoginInfo agentLoginObject)
{
string agentID = "";
string agentPassword = "";
try
{
if (agentLoginObject != null)
{
agentID = agentLoginObject.AgentId;
agentPassword = agentLoginObject.AgentPassword;
}
else
{
Console.Write("No Data");
}
}
catch (Exception e)
{
Console.Write("Error :" + e.Message);
}
RequestBLObject.AgentID = agentLoginObject.AgentId.Trim();
RequestBLObject.AgentPassword = agentLoginObject.AgentPassword.Trim();
DataTable UserDetails = new DataTable();
UserDetails = BehaviourBLObject.ValidateUsernamePasswordBL(RequestBLObject);
}
And this is my ajax call:
function Login() {
var agentLoginObject = {};
var ID =$("#AgentID").val();
var Password =$("#Password").val();
agentLoginObject.AgentID = ID;
agentLoginObject.AgentPassword = Password;
alert(JSON.stringify(agentLoginObject));
$.ajax({
method: 'POST',
url: 'http://arohar.com/Service.asmx/LoginOnClick',
data: "{agentLoginObject:"+ JSON.stringify(agentLoginObject)+"}",
// data: JSON.stringify(agentLoginObject),
processData: false,
dataType: 'JSON',
success: function() {
alert("success");
},
error: function() {
alert("error");
}
});
}