JQuery post not working - Not even an error message

They have: 426 posts

Joined: Feb 2005

My jquery post is not working and not even giving me any error messages?

I had the same function working on another site, yet this one fails to work. The function is firing because my alert works. I cannot alert anything from within the sucess function:

function sendMail(){
   //alert('hello');
  $.post("sendmail.php", $("#contacts-form").serialize(),function(data){
    switch (data){
      case '1':
        $('#emailmessage').html('Email Invalid, please try again.');
        alert('Email invalid');
        break;
     
      case '2':
        $('#emailmessage').html('You need to complete all fields.');
        break;
       
      case '3':
        clear_form_elements('#contacts-form');
        $('#emailmessage').html('Message sent. We will reply within 24 hours.');
        setTimeout("$('#emailmessage').html('')",3000);      
        break;
       
      case '4':
        clear_form_elements('#contacts-form');
        $('#emailmessage').html('Sorry. There was a problem and the message could not be sent.');
        break;           
    }
    return false;     
  });  
}

Any help appreciated.

teammatt3's picture

He has: 2,102 posts

Joined: Sep 2003

Are you sure sendmail.php is working? Is that the correct path to the file? If you get 404 or 503 on sendmail.php, the success function will not fire.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.