运行在AJAX加载的内容JQuery的脚本 [英] Running JQuery scripts on AJAX loaded content

查看:125
本文介绍了运行在AJAX加载的内容JQuery的脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用.load()拉静态HTML文件到我的HTML主页。我写的剧本和选择中存在:

  $(文件)。就绪(函数(){});
 

但他们并没有对AJAX加载的内容合作。我已阅读,这是因为不可用,我现在用的选择。

有没有更好的方式来做到这一点?添加脚本来window.load功能也不起作用:

  $(窗口).load(函数(){});
 

解决方案

  $(文件).ajaxComplete(函数(){
    //火灾时,任何Ajax请求完成
})
 

ajaxComplete()

I am using .load() to pull static HTML files onto my main HTML page. The scripts and selectors that I have written exist within:

$(document).ready(function(){});

But they don't work on the AJAX loaded content. I have read that this is because the selectors that I am using are not available.

Is there a better way to do this? Adding the script to the window.load function doesn't work either:

$(window).load(function() {});

解决方案

$(document).ajaxComplete(function(){
    // fire when any Ajax requests complete
})

ajaxComplete()

这篇关于运行在AJAX加载的内容JQuery的脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆