Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Mar 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Js Alert() doesn't work in IE?

    Hi, Sorry to ask a question with my first post, but here it is.

    I have the following script to show a js alert box on the successful completion/submission of a contact form. On chrome and firefox it displays ok but with IE, nothing is shown.

    Any ideas?

    Thx for any suggestions/help.

    $.ajax({

    url: '/*****/modules/contact_us/ContactUsProcess.class.php',
    type: 'POST',
    cache:false,
    data: $('#frmContactUs').serialize(),
    success: function(data) {
    if (data == 'success') {
    alert('successful submission');
    $('#frmContactUs')[0].reset();
    } else {
    alert(data);
    }
    }
    });

    }

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,396
    Thanks
    12
    Thanked 569 Times in 562 Posts
    This piece of code is just fine ... you should try to observe the request using the development tools of your choice and adding an "error" callback

    Code:
    $.ajax({
    
       url: '/*****/modules/contact_us/ContactUsProcess.class.php',
       type: 'POST',
       cache:false,
       data: $('#frmContactUs').serialize(),
       success: function(data) {
          if (data == 'success') {
             alert('successful submission');
             $('#frmContactUs')[0].reset();
          } else {
             alert(data);
          }
       },
       error: function(jqXHR, textStatus, errorThrown) {
          alert('Error: ' + errorThrown + ' (' + jqXHR.status + ' / ' + textStatus + ')');
       }
    });

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,611
    Thanks
    0
    Thanked 645 Times in 635 Posts
    Just don't forget to replace the debugging alerts once you have finished debugging. There should be no alerts in the code when it goes live as they allow disabling JavaScript or further alerts (depending on which browser is being used) to make debugging easier.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    You may need to specify dataType option.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •