Hi All,
As i am new to jquery and php, I was stuck at 1 point,
I have a login form with emailid and password in html. and i have written a webservice,if user logs in successfully then show home.html page else show login.html page.
Everything is working fine i.e. webservice in php is working fine. When i check using google chromes breakpoint and F10 then the result is showing correctly i.e. if user is abc@gmail.com and password is abc then it gives me the home.html page but this happens only when i use google chromes breakpoint,then only it shows me the correct result but it i try to run directly without any breakpoint then it shows me error with blank message.
Do you have any suggession on where i am going wrong.
$('#form').submit(function()
{
var emailid = null;
var password = null;
var userData=null;
emailid= $('#emailid').val();
password= $('#password').val();
userData='emailid='+ emailid +'password='+ password;
alert(userData);
if(emailid && password)
{
Authenticate_User(userData);
}
else
{
alert('Email id and password cannot be blank');
}
});
function Authenticate_User(userData)
{
$.ajax({
url: 'services/Login.php',
type: 'POST',
data: userData,
contentType: 'application/x-www-form-urlencoded',
dataType: "json",
processData: false,
success: function(XMLHttpRequest,textStatus,errorThrown)
{
alert('Success is here');
console.log('Success is here' + JSON.stringify(XMLHttpRequest.responseText));
window.location.href = "home.html";
},
error: function(XMLHttpRequest,textStatus,errorThrown)
{
console.log('ERROR: ' + JSON.stringify(XMLHttpRequest.responseText));
alert(JSON.stringify(XMLHttpRequest.responseText));
}
}).done(function(data) { console.log(data); })
.fail(function() { alert("error"); })
.always(function() { alert("complete"); });
}