Could not convert javascript argument
12,252
I don't think you can append an array. Change:
$('#project').append(projGallery);
To:
$.each(projGallery, function(idx, val) {
$('#project').append(val);
});
Comments
-
Adgezaza almost 2 years
After trying to append some code to a div layer I received the following error and don't know why.
uncaught exception: [Exception... "Could not convert JavaScript argument 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]
Below is the code that is causing the error. I understand there is some excessive code but I made it that way so it would be easy to build on for future features. Just looking for any suggestions for the error? Thank You! :)
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"); } } }); }