I built a rudimentary page navigation system with jQuery. You click the next button, it retrieves the next page via AJAX; click the previous, it goes to the one before it, etc. The AJAX request is done via the jQuery $('#dom').html().load()
method.
我用jQuery构建了一个基本的页面导航系统。单击next按钮,它通过AJAX检索下一页;单击前面的,它将转到前面的那个,等等。AJAX请求是通过jQuery $('#dom').html().load()方法完成的。
Inside one of the pages pulled is an a href link with an onclick which goes to a custom function (loadPage()
-- the same function I'm using for the parent page navigation). As you can guess, the onclick
event used inside the AJAX page does not work -- it's trying to call a function that doesn't exist.
在拉出的一个页面中,有一个带有onclick的a href链接,该链接指向一个自定义函数(loadPage()——我在父页面导航中使用的函数)。可以猜到,AJAX页面中使用的onclick事件不起作用——它试图调用一个不存在的函数。
Is there a simple way to make this work? Perhaps some other jQuery AJAX method like GET? Thanks in advance.
有没有一种简单的方法可以让它工作?也许还有其他jQuery AJAX方法,比如GET?提前谢谢。
1 个解决方案
#1
3
It sounds like you are embedding JavaScript into your html. Don't do that. Put your JavaScript into an external file and include it with a script tag, just like you do with jQuery.
这听起来像是你在html中嵌入了JavaScript。不要这样做。将JavaScript放入一个外部文件,并将其包含在一个脚本标记中,就像使用jQuery一样。
#1
3
It sounds like you are embedding JavaScript into your html. Don't do that. Put your JavaScript into an external file and include it with a script tag, just like you do with jQuery.
这听起来像是你在html中嵌入了JavaScript。不要这样做。将JavaScript放入一个外部文件,并将其包含在一个脚本标记中,就像使用jQuery一样。