Jquery ajax成功完全不起作用

时间:2013-04-20 15:32:27

标签: jquery ajax

我正在开发一个通知系统,我在修复类或做除了html()之外的任何事情以及在ajax成功中追加()时遇到了问题。这是我的代码:

    setInterval(function (){
    $(".notificare_caseta").each(function(){
        var id=$(this).attr("record");
        $.ajax({
            url : "../template/functions/notificari.php?nr="+id,                          
            contentType: "application/json; charset=utf-8",
            dataType:"JSON",                   
            success : function(data) {  
                $(".notificari_zona"+id).html(data.notif);
                if(data.note>0){
                    $(".notificari_note"+id).html(data.note);
                }else{
                    $(".notificari_note"+id).addClass('nu_arata');
                    $(".notificari_note"+id).prev().removeClass("atentionare");
                    $(".notificari_note"+id).next().addClass("nu_arata");
                }
            }
        });                 
    });

    $("#data").load("../template/functions/data.php");

}, 2000);

任何人都可以帮助我吗? next,prev,removeclass,addclass函数不起作用。感谢

1 个答案:

答案 0 :(得分:0)

我重写了发送数据和回来的功能。

setInterval(function (){
    var ids = [];
    $(".notificare_caseta").each(function(){
        ids.push($(this).attr("record"));
    });
    $.ajax({
        url : "notificari.php",
        data : {"nr":ids},
        dataType:"JSON",
        success : function(data) {  
            //here you should get the all data togther for ex [{"notif":1,"note":1},{"notif":2,"note":2},{"notif":3,"note":3}]
            $.each(data,function(i,x){
                $(".notificari_zona"+ids[x]).html(i.notif);
                if(i.note>0){
                    $(".notificari_note"+ids[x]).html(i.note);
                }else{
                    modify(".notificari_note"+ids[x]);
                }
            })
        }
    });                 


    // $("#data").load("../template/functions/data.php");

}, 10000);
相关问题