更新时间:2023-11-01 21:08:22
绑定事件或调用jQuery函数时,该元素需要存在于DOM中,jQuery才能找到它.
When you bind events, or call jQuery functions, the element needs to exist in the DOM for jQuery to find it.
因为在脚本执行后 中填充了页面,所以没有要选择的元素(尽管将选择放置在document.ready
回调中.
Because you are populating your page after the script has executed, there's no element's to be selected (despite placing the selection in a document.ready
callback.
如果在$('div#controller')
上执行了console.log
,则会看到一个空的jQuery对象.
If you did a console.log
on $('div#controller')
you'd see an empty jQuery object.
相反,如果您使用完整的回调来注册您的jsFlow
调用,您应该会看到一切正常.
If you, instead, used the complete callback to register your jsFlow
call, you should see things working as expected.
您是否没有使用jQuery规范化的 ajax 函数的原因?
Is there a reason you're not using jQuery's normalized ajax functions?