views:

21

answers:

1

this is my website i develop http://alessandro.babonmultimedia.com/ when we clicked at contact (navigation at top), there will be contact us form loaded via jquery AJAX,

the question is:

  1. when we click submit, it will sending mail.

this is work in Firefox 3.6.1, but in google chrome 7.0.517.41 the submit button do nothing..

  1. why this can be happen?
  2. is there a way to make it work?
  3. what is the best method to implement AJAX JavaScript, when the selector we are targeting is loaded via javascript (i first use $(document).ready(), but this not work for content loaded via AJAX :( )

Thx..

+1  A: 

Looking at my error log it seems you are still referencing console. If the console isn't open then window.console is undefined and will halt execution.

function contact_us(){
    /**************REMOVE*******************/
    console.log('AJAXnya start');
    /**************THIS*******************/
    $('#contactus form').fadeTo('slow', .2);
    $.ajax({
        type    : 'POST',
        url : '/wp-content/themes/second-edition/js/form-contactus.php',
        dataType    : 'json',
        data    : {
            name        : $('#contactus input[name="name"]').val(),
            surname : $('#contactus input[name="surname"]').val(),
            email   : $('#contactus input[name="email"]').val(),
            website : $('#contactus input[name="website"]').val(),
            message : $('#contactus textarea[name="message"]').val()
        },
        success : function(data){
            alert(data.msg);
            $('#contactus form').fadeTo('slow', 1);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown){
            alert('There Was an Error, please contact Web Administrator');
        }
    });
}
Josh K
oh you right, i develop this website using firefox firebug which console.log() have a function, but in chrome, there is no such function console.log. Thanks you very much. my script now working correctly
GusDe CooL
@Gusde why console.log throws error in chrome , for me its work in chrome also. go to chrome developer tool bar you can see them
gov