For some reason the success and error callbacks are not working at all. I'm using jquery.ajax to submit a form w/o page refresh through a php file. I have set the success & error callbacks but even when I changed the mysql password (to a incorrect one) I got the success message :S
$connect = mysql_connect("localhost", "root", "password") or die ("Unable to connect to the database");
mysql_select_db("ipsum") or die ("doesnt exist: " . mysql_error());
As far as jQuery is concerned, the Ajax request is always successful if the HTTP result is code 200. In other words, the failure function will only trigger on an HTTP error page. If, for example, you changed the URL to "file_that_doesnt_exist.php," a file that doesn't exist and returns an HTTP status code: 404 (file not found), then your failure function would trigger instead.
To solve your problem, write some code in your success function that distinguishes when your result is favorable and when it is not. (In other words, check if the data returned from "update.php" contains the phrase "unable to update." If it does, then you should proceed with an action that indicates the server-side functionality failed to meet expectations; otherwise, proceed with the default action for your success function.)
Visit Slightly Remarkable to see my portfolio, resumé, and consulting rates.
Bookmarks