无法转换javascript参数

Adg*_*aza 15 javascript ajax jquery parsing append

尝试将一些代码附加到div层后,我收到以下错误,不知道为什么.

未捕获的异常:[Exception ..."无法转换JavaScript参数arg 0 [nsIDOMDocumentFragment.appendChild]"nsresult:"0x80570009(NS_ERROR_XPC_BAD_CONVERT_JS)"location:"JS frame :: http://code.jquery.com/jquery-latest .min.js :: anonymous :: line 113"data:no]

下面是导致错误的代码.我知道有一些过多的代码,但我这样做,所以很容易为未来的功能构建.只是寻找任何错误的建议?谢谢!:)

 function catSelect(itm){ 

  //params for query
  var params = { 
   category: itm
  };

  var cmd = jQuery.param(params);

  $.ajax({
   async: false,
   type: "POST",
   cache: false,
   url: "views/gallery.php",
   data: cmd,
   dataType: "json",
   success: function(resp){
    if(resp.status == "ok") {
     $('#project').empty();
     //alert(resp.projects[0]);alert(resp.files[0]); alert(resp.titles[0]);
     var check = 0;
     var projGallery = new Array();
     for(var i in resp.projects){
      if(check!=resp.projects[i] || check == 0){
       projGallery[i] ='<a class="group" title="'+resp.titles[i]+'" href="images/gallery/"'+resp.files[i]+'" rel="'+resp.projects[i]+'" ><img class="group" alt="" src="../images/gallery/thumbs/"'+resp.files[i]+'"/></a>';  
      } else {
       projGallery[i] ='<a class="group" rel="'+resp.projects[i]+'" href="images/gallery/"'+resp.files[i]+'" title="'+resp.titles[i]+'"></a>';
      }
      check = resp.projects[i];
     }
     //alert(projGallery[0]);
     alert(projGallery);
     $('#project').append(projGallery);
    } else {
     alert("Failed to select projects");
    }
   }
  }); 
 }
Run Code Online (Sandbox Code Playgroud)

小智 16

我不认为你可以附加一个数组.更改:

$('#project').append(projGallery);
Run Code Online (Sandbox Code Playgroud)

至:

$.each(projGallery, function(idx, val) {
    $('#project').append(val);
});
Run Code Online (Sandbox Code Playgroud)