-2
function getProject(){
    var postData = {
        'project' : proj_id
    };

    //console.log(postData);
    var site_url = "<?php echo site_url('/'); ?>";
    $.ajax({
        type: "POST",
        url: site_url + "maincontroller/project",
        data: postData, //assign the var here 
        success: function(msg) {
            $("#project").html(msg);
            getSubProject();                              
        }
    });

假设这是一个函数,现在我想对 AJAX 响应应用条件,响应 id 为<div id="project"></div>. 如果响应成功,则生成此 div,否则不生成。任何人都可以帮助我吗?

4

2 回答 2

4

代替

$("#project")=.html(msg);

$("#project").html(msg);
于 2013-09-10T11:04:47.370 回答
0

尝试这个

success: function(msg, status){
       if (status == 200) {// ok 

       $("#project").html(msg);

            getSubProject();                             
      }
}
于 2013-09-10T11:07:18.680 回答