有没有办法为同一页面上的不同元素执行不同的功能?
$('.class1').click(function() {
$.ajax({ url:'pages/page1.php?id1='+this.id,
success:function(data){
$("#Loading").fadeOut('fast'); //hide when data's ready
$("#homeContent").html(data);
} });
});
$('.class2').click(function() {
$.ajax({ url:'pages/page2.php?id2='+this.id,
success:function(data){
$("#Loading").fadeOut('fast'); //hide when data's ready
$("#homeContent").html(data);
} });
});
我使用的是萤火虫,当我进行不同的点击时,它会堆叠获取请求,如下所示:
GET http://127.0.0.1/pages/jemissoes.php?id=1 (1st click)
GET http://127.0.0.1/pages/jemissoes.php?id=2 (2nd click)
GET http://127.0.0.1/pages/jemissoes.php?id=2
GET http://127.0.0.1/pages/jemissoes.php?id=3 (3rd click)
GET http://127.0.0.1/pages/jemissoes.php?id=3
GET http://127.0.0.1/pages/jemissoes.php?id=3
谢谢