Breezy
Breezy

Reputation: 21

ajax form submits fine, but success does not work?

I have a simple form that submits with jquery and ajax. the form submits fine and the data posts, but the success message will not call... just the error message. can someone tell me what I am doing wrong.

    <script type="text/javascript" >
$(function() {
$(".form-submit").click(function() {                        
var esn = $("#esn").val();

var dataString = 'esn='+esn;

if(esn=='')
{
$('.error').show().fadeOut(3000);
}
else
{
$.ajax({
type: "post",
url: "include/submit_repair_form.php",
data: dataString,
success: function(result) {
    alert(result);  
    $('.testing').hide(); 
  },
  error:function (xhr, ajaxOptions, thrownError){
    alert(xhr.statusText);
  }   
});
}
return false;
});
});
</script>

Upvotes: 0

Views: 150

Answers (1)

Rob
Rob

Reputation: 4947

You forgot to set the result variable in function()

Like this:

success: function(result) {
    alert(result);  
    $('.testing').hide(); 
  }

Upvotes: 1

Related Questions