1
I have that code:
$("#go").click(function(){
var email = $("#email").val();
var password = $("#password").val();
$.ajax({
dataType:'html',
type: 'post',
data: 'email=' + email + '&password=' + password,
url: 'login.php',
success: function(data){
alert(data);
},
error: function(data){
alert("Error");
}
});
});
which generates the following request to the server:
Request URL:http://localhost/Snotes/login.php
Request Headers CAUTION: Provisional headers are shown.
Accept:text/html, */*; q=0.01
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Origin:http://localhost
Referer:http://localhost/Snotes/index.php
User-Agent:Mozilla/5.0 (Windows NT 6.3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36
X-Requested-With:XMLHttpRequest
Form Dataview sourceview URL encoded
email:123
password:123
The request url is correct and the data is correct, but the error function is always called, in the Chrome network tab it says the status is 'canceled', someone can help me with this error?
the error alert is executed? which returns in the login page.php?
– Kallef
if authentication has been done it returns the user id, otherwise it returns 0, the php script writes in the body of the page with 'echo' the quoted values
– ProgramandoMil
If you’re falling in the callback
error
is because it is giving error in php. You posted the request headers, check also the headers and the response content, the error will appear there.– bfavaretto
In Sponse is talking 'Failed to load Response data', however when I use the Debugger and run until jQuery finishes the whole process, the request works(calls Success but the Answer tab still has the same failure message), and when not debugging it does not work(calls error).
– ProgramandoMil
Which code is giving?
– bfavaretto
'Failed to load Response data is what appears in Response, with the 'complete' method I got an error status message where the error code is 0 and the error message is simply "error"
– ProgramandoMil