I'm looking for a simple example and/or explanation of how to use the error
parameter for .ajax
.
This question (jQuery ajax error function) points to this jQuery documentation (http://api.jquery.com/jQuery.ajax/) which I do not understand.
I have the following code that does not work and I can't figure out why. I'm hoping the error parameter will help:
jquery:
<script>
// wait for the DOM to be loaded
$(document).ready(function() {
// bind 'myForm' and provide a simple callback function
$("#myForm").submit(function(){
var user_input = $("#signup_id_email").val();
$.ajax
({
type: "POST",
url: "ajax_test.php",
dataType: 'json',
data: {email: user_input},
**error: ""**
})
.done(function(r)
{
$("#answer_id").append(r.email);
});
});
});
</script>
PHP (ajax_text.php)
<?php
echo json_encode($_POST);
?>