Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- How to handle mysql error inside ajax?


Fotiman - 1:50 pm on May 17, 2012 (gmt 0)


You need to modify process/subscribe_process.php to return something. For example, here's some pseudo code:

<?php
// susbscribe_process.php
// insert into database
// if no problems
// echo "success";
// else
// echo "error";
?>

And then:

$.ajax({
type: "POST",
url: "process/subscribe_process.php",
data: dataString,
dataType: "text",
success: function(data) {
if (data == "success") {
$("#message").html("Everything's good!");
}
else {
// there was an error
}
},
error: function() {
$("#message").html("Error!");
}
});


Thread source:: http://www.webmasterworld.com/javascript/4454570.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com