jQuery的阿贾克斯加载动态内容 [英] Jquery Ajax loading dynamic content

查看:312
本文介绍了jQuery的阿贾克斯加载动态内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有执行的code .. $ C $以下行C包含2部分的问题。 一个是一个简单的HTML文件必须通过的Ajax调用另一个HTML页面。

I am having the problem with executing the following lines of code..Code contain 2 part. One is a simple HTML file have a call to another Html page through Ajax.

<html>
<head>
<title>
</title>
<script language="javascript" src="jquery-1.7.1.js"></script>
<script language="javascript">
$(document).ready(function(){
$("#btn").click(function(){
$.ajax({
type: 'GET',
url: 'check.html',
cache:false,
success: function callme(html){
document.getElementById('display').innerHTML=html;
}
});
});
});
</script>
</head>
<body>
<form>
<input type="button" id="btn" value="Click"/>
</form>
<div id="display"></div>
</body>

<html>
<head>
<title>
</title>
<script language="javascript" src="jquery-1.7.1.js"></script>
<script language="javascript">
$(document).ready(function(){
$("#btn").click(function(){
$("#btn").hide();
});
});
</script>
</head>
<body>
<input type="button" id="btn" value="Click"/>
</body>
</html>

问题是,当我尝试点击page1.html的按钮,它会毫不掩饰check.html的jQuery的一部分的按钮,但如果我只是运行check.html页面将隐藏按钮immediately.I唐知道问题出在哪里。

problem is that when I try to click the button of page1.html it will not hide the button of the jquery part of check.html but if I simply run the check.html page it will hide the button immediately.I don't know where is the problem.

推荐答案

在加载页面的check.html那么你有两次BTN页面上的ID。

When you load the check.html in your page then you have two times the id btn on the page.

您是否尝试过改变这种状况,看看是否能解决问题?

Have you tried to change that and see if that solves the problem?

这篇关于jQuery的阿贾克斯加载动态内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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