返回未定义的jQuery效果

返回未定义的jQuery效果,jquery,jquery-ui,highlight,effect,Jquery,Jquery Ui,Highlight,Effect,我有以下街区: $('.new_comment').live('ajax:success', function(evt, data, status, xhr){ $('.comments article:last').after(xhr.responseText).effect("highlight", {}, 3000); }) 因此,当提交new_comment表单时,它会调用此函数 after()函数工作正常,但effect()调用引发以下错误: TypeError: 'undefi

我有以下街区:

$('.new_comment').live('ajax:success', function(evt, data, status, xhr){
  $('.comments article:last').after(xhr.responseText).effect("highlight", {}, 3000);
})
因此,当提交
new_comment
表单时,它会调用此函数

after()
函数工作正常,但
effect()
调用引发以下错误:

TypeError: 'undefined' is not a function (evaluating '$('.comments article:last').after(xhr.responseText).effect("highlight", {}, 3000)')
我正在使用jQuery1.7.1和jQueryUI1.8.16

更新:
xhr.responseText
返回新创建的
文章
元素,如下所示:

<article id="2">
  <h6><a href="#">Joe</a> <span>(<a href="#2">less than a minute ago</a>)</span></h6>
  <p>This is the new comment!</p>
</article>
<section class="comments">
  <h3>Comments</h3>
  <article id="1">
    <h6><a href="#">Joe</a> <span>(<a href="#1">less than a minute ago</a>)</span></h6>
    <p>This is a comment!</p>
  </article>
  <article id="2">
    <h6><a href="#">Joe</a> <span>(<a href="#2">less than a minute ago</a>)</span></h6>
    <p>This is the new comment!</p>
  </article>
</section>

另外,如果我运行
console.log($('.comments-article:last'),它肯定会返回创建的对象。

由于ajax post未链接到父容器而创建的新元素。新名称空间似乎是通过发布创建的。因此,您不能触摸未在post函数的结果部分定义的页面正文的任何元素。

我解决了这个问题。我加载了两次jQuery库。一次使用Rails的预捆绑版本,一次使用Google的CDN。移除其中一个,现在所有工作正常。叹息。

服务器端脚本返回的xhr.responseText的值是多少?出于调试目的,如果将其分解为两条语句,如:$('.comments article:last')。after(xhr.responseText)$('.comments-article:last').effect(“highlight”,{},3000)@Joris:
xhr.responseText
返回新创建的
文章
element@MichaelRighi同样的错误也会发生。@Shpigford在调用.after()之后,您能告诉我们生成的DOM是什么样子吗?