0

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>
Breezy
  • 21
  • 6

1 Answers1

1

You forgot to set the result variable in function()

Like this:

success: function(result) {
    alert(result);  
    $('.testing').hide(); 
  }
Rob
  • 4,927
  • 12
  • 49
  • 54
  • 1
    Try `console.log(result);` instead of `alert(result);`. You might get some extra info – Rob Mar 12 '13 at 12:17
  • the script for the form is called on another server... does that matter? – Breezy Mar 12 '13 at 12:21
  • k so in order to get a success result the url: has to be on the same server? – Breezy Mar 12 '13 at 12:25
  • Yes, and you can't use post... Take a look at this: http://stackoverflow.com/questions/2681466/jsonp-with-jquery – Rob Mar 12 '13 at 12:26