Jquery点击功能相同的脚本

时间:2012-09-09 00:27:10

标签: jquery ajax click

有没有办法在同一页面上为不同的元素执行diferente func?

$('.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);
         } });
});

我使用的是firebug,当我进行不同的点击时,它会堆叠获取请求,如下所示:

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

由于

0 个答案:

没有答案