Uncaught SyntaxError: Unexpected token <?

Javascript:

jQuery(document).ready(function() {
    jQuery('#submit').click(function() {         

        jQuery("#LoadingImage").show();

        var imgSrc = 'http://foo.com/gen.php?username1=' + jQuery('input[name=username1]').val() + '&amp;username2='+ jQuery('input[name=username2]').val();

        jQuery('#imgRESULT').html('<img id="image1" src="' + imgSrc + '" >');
    });

    $('#image1').on("load", (function() {
        $("#LoadingImage").hide();
    });
});

With the html being

<div id="LoadingImage" style="display: none">
<img src.... /></div>​<div align="center" id="imgRESULT"></div>

and with the correct inputs etc.

But going into the console I get:

(Uncaught SyntaxError: Unexpected token <)

I can't seem to see how to get this script working. Any input?


                        V--------------extra parenthesis
$('#image1').on("load", (function() {
    $("#LoadingImage").hide(); }); <---extra parenthesis
});

Needs to be:

$('#image1').on("load", function() {
    $("#LoadingImage").hide();
});

You have an extra parenthesis before the function statement. Also switched out jQuery() to $() for appearances.

链接地址: http://www.djcxy.com/p/46000.html

上一篇: 未捕获的SyntaxError:队列中的意外令牌var

下一篇: 未捕获的SyntaxError:意外的标记<?