0

Dreamweaver 在文件中显示错误

jquery.jig.js

文件是这个

jQuery(document).ready(function(){
    $('#contactform').submit(function(){
    var action = $(this).attr('action');
    $('#submit').attr('disabled','disabled').after('<img src="contact-form/assets/ajax-loader.gif" class="loader" />');
    $("#message").slideUp(750,function() {
    $('#message').hide();      
    $.ajax({
        type:"POST",
        url: "yourPhpFileURL.php",   //put the url of your php file here
        data: $('#contactform').serialize(),
        success: function(data){
            document.getElementById('message').innerHTML = data;
            $('#message').slideDown('slow');
            $('#contactform img.loader').fadeOut('fast',function(){$(this).remove()});
            $('#submit').removeAttr('disabled');
            if(data.match('success') != null) $('#contactform').slideUp('slow');

            if(data.match('success') != null) $("html,body").animate({
                scrollTop: $("#message").offset().top
                }, 1000, function(){

                });
            if(data.match('success') == null) $("html,body").animate({
                scrollTop: $("#message").offset().top
                }, 1000, function(){
                    //scroll complete function
                });                     
        }
        });

    });

    return false;

});

});

错误显示在最后一行,但我无法理解原因。

4

1 回答 1

1

我通过jsfiddle的 JSLint 语法分析器运行了您的代码,并修复了一些错误等。到目前为止,以下验证正常。请在您的最后检查它:

jQuery(document).ready(function() {
    $('#contactform').submit(function() {
        var action = $(this).attr('action');
        $('#submit').attr('disabled', 'disabled').after('<img src="contact-form/assets/ajax-loader.gif" class="loader" />');
        $("#message").slideUp(750, function() {
            $('#message').hide();
            $.ajax({
                type: "POST",
                url: "yourPhpFileURL.php",
                //put the url of your php file here
                data: $('#contactform').serialize(),
                success: function(data) {
                    document.getElementById('message').innerHTML = data;
                    $('#message').slideDown('slow');
                    $('#contactform img.loader').fadeOut('fast', function() {
                        $(this).remove();
                    });
                    $('#submit').removeAttr('disabled');
                    if (data.match('success') !== null) {
                        $('#contactform').slideUp('slow');
                    }
                    var msg_offset = $("#message").offset().top;
                    if (data.match('success') !== null) {
                        $("html,body").animate({
                            scrollTop: msg_offset
                        }, 1000, function() {

                        });
                    }
                    if (data.match('success') === null) {
                        $("html,body").animate({
                            scrollTop: msg_offset
                        }, 1000, function() {
                            //scroll complete function
                        });
                    }
                }
            });

        });

        return false;

    });

});
于 2012-09-21T02:05:51.863 回答