in default.aspx i am calling web method. bt every time its going to error method.
code is...
function login(btn) {
alert('a');
var email = document.getElementById("txtUserName").value;
var password = document.getElementById("txtPass").value;
if (email == "" || password == "") {
alert('Fill up data');
return;
}
else {
/* send the link to fetch details */
var check = CheckRadio(btn);
var input = email + " " + password + " " + check;/* detect by space */
alert(input);
$.ajax(
{
type: 'POST',
url: '/Default.aspx/Login',
data: '{\'inputText\':\'' + input + '\'}',
dataType: 'json',
contentType: 'application/json; charset=utf-8',
success: function (response) {
if (response != null && response.d != null) {
alert('done');
}
},
failure: function (response) {
alert('Sorry! Operation failed.');
},
error: function (response) {
alert('Sorry! Error.');
},
});
}
function CheckRadio(rd) {
var tr = rd.parentNode.parentNode;
var radiobutton = tr.getElementsByTagName('input');
for (var i = 0; i < radiobutton.length; i++) {
if (radiobutton[i].checked) {
return (radiobutton[i].nextSibling.textContent);
}
}
}
webmethod :
[WebMethod(EnableSession = true)]
public string Login(string inputText)
{
int i = 0;
string[] ip = inputText.Split(' ');
User_DAL obj = new User_DAL();
DataTable dt = obj.Login(ip[0].ToString(), ip[1].ToString(), ip[2].ToString());
if (dt.Rows.Count >= 1)
return string.Format("{0}", "Success");
else
return string.Format("{0}", "Wrong email & password !");
}
thank u..