Jquery 链接(来自其他页面的ajax响应)不使用ajax
这是action.php在我的页面上的输出。来自firebug:Jquery 链接(来自其他页面的ajax响应)不使用ajax,jquery,ajax,Jquery,Ajax,这是action.php在我的页面上的输出。来自firebug: <html> <body> <table> <tr> <th>Trainer Available</th> </tr> <tr> <td style='width: 200px;'> <a
<html>
<body>
<table>
<tr>
<th>Trainer Available</th>
</tr>
<tr>
<td style='width: 200px;'>
<a href='http://appsmarketing.net/free/action.php?me=1' id='member' class='member' >trainer1</a>
</td>
</tr>
<tr>
<td style='width: 200px;'>
<a href='http://appsmarketing.net/free/action.php?me=2' id='member' class='member' >trainer2</a>
</td>
</tr>
</table>
</body>
</html>
当我点击这个按钮时,它会转到url post,没有使用ajax
当用户单击此链接时,我正在使用脚本运行。它使用的是普通的锚定选项卡,但使用的是特定的url,而不是返回ajax调用页面。。实际上,当我点击链接时,并没有像firebug中那样使用ajax。。这是什么问题?我感谢任何帮助我的人,因为我珍惜你的时间
这是我使用的脚本
<script>
$(document).ready(function(){
$('a.member').click(function(e){
$.ajax({
type: "GET",
url: this.href,
cache:false,
success: function(data){
$("#result2").append(data);
}
});
return false;
});
});
</script>
$(文档).ready(函数(){
$('a.member')。单击(函数(e){
$.ajax({
键入:“获取”,
url:this.href,
cache:false,
成功:功能(数据){
$(“#结果2”)。追加(数据);
}
});
返回false;
});
});
使用普通的htmla
标记,它可以工作。。
感谢进步…您有两个ID为
成员的元素。ID应始终是唯一的。无论如何,您应该删除这两个ID,因为您已经使用了类
它不起作用,因为当您尝试将单击事件绑定到它时,a.member
不存在。您可以通过将事件绑定到加载页面时存在的容器(例如#tabs-2
)来防止此问题:
$('#tabs-2').on('click', 'a.member', function(e) {
e.preventDefault();
(rest of the code)
}
谢谢你的回复,但它不起作用。我删除了链接的id,包括默认的。你能提供一个到这个页面的链接吗?或者,请包括您页面的所有相关部分并更新您的代码片段。如果我提供当前正在编码的在线url,可以吗?或者告诉您是个坏主意??我用它只是为了学习@如果只是为了学习,我想这不会是个问题。。。另一种方法是将所有内容粘贴到服务中,就像我单击trainer1或trainer2链接时,它会转到特定页面
$('#tabs-2').on('click', 'a.member', function(e) {
e.preventDefault();
(rest of the code)
}