开发者

Run all jQuery/prototype document.ready functions manually

I use AJAX to load some content to the page, and that content has some jQuery(document).ready() code in it. I need for the stuff in the ready function to execute, but I cannot modify the actual code, but only use wha开发者_如何转开发t's been provided by server via AJAX.

How to trigger those functions in jQuery 1.4+ / Prototype?

Basically, what I need to do is to execute an inline javascript code from a HTML response.


You could try an eval(code) of the code that comes from another source. When using Ajax you have to specify what kind of output are you expecting (dataType for jQuery Ajax call). This can be xml, json, script, or html. Unless you are doing JsonP and you import a script the other datatypes are basically text and you need to eval them in order to execute them. Once you eval() them the functions from the other source will be available in your global environment.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜