为什么下面的jquery代码不能运行呢?

Why doesn't the following piece of jquery run?

本文关键字:不能 运行 代码 jquery 为什么      更新时间:2023-09-26

我试图用jquery/ajax获取一些html,将其加载到div中,然后调用带有盲目效果的show方法。但是我不知道我这辈子到底出了什么问题。

 $(document).ready(function() { // The relevant jQuery
    $("#effect").hide(); // Make sure the div I'm going to show is not visible first off.
    $("#foo").click(function(){  // foo is a button
        $.ajax({url:"after.html", success:function(result){ // Grab the html I want.  (just an <h1> tag)
            $("#effect").html(result).show("blind", {direction: "horizontal"}, 400); // When I comment out this line it works, but with the exception of the id's to select it's exactly the same as in another working page.
            alert("loaded after.html...");
        }});
    });
});
HTML:

<div class="narrow">
   <p><input type="submit" id="foo"/></p>
</div>

<div id="effect" style="background-color:white; float:right; height:400px; width:400px;">
</div>

不调用$("#effect").html(result).show("blind", {direction: "horizontal"}, 400);行,一切运行正常。然而,这一行在控制台中显示为Uncaught SyntaxError: Unexpected end of input。(铬)

当我遇到这个问题时,我正在使用这个页面作为参考。

这是怎么回事?

盲目效果是JQueryUI的一部分。在您分享的教程中,您可以看到该代码。你确定像jquery-ui-1.7.2.custom.min.js这样的东西在你的页面上被引用为:

<script type="text/javascript" src="/jquery/jquery-ui-1.7.2.custom.min.js"></script>