简体   繁体   English

未捕获的错误NOT_FOUND_ERR DOM异常8

[英]uncaught error NOT_FOUND_ERR DOM Exception 8

So I am deleting all the contents under a particular div and adding a message content. 所以我删除特定div下的所有内容并添加消息内容。 However, javascript throw the following error after the finish: 但是,javascript在完成后抛出以下错误:

Uncaught Error: NOT_FOUND_ERR: DOM Exception 8

Here is the code where it is executed 这是执行它的代码

 new Ajax.Request("profileThis.php",
 {
   method:'post',

   parameters:{title:title, review:review, userId:userId, category:category, categoryId:categoryId},

   onSuccess:function(ajax) 
   {
    alert(ajax.responseText); // this is just for debugging purposes

    var message=ajax.responseText;

    var divMessage=document.createElement("div");

    divMessage.style.color="rgb:(105,105,105)";

    divMessage.innerHTML=message;

    while($("reviewSheet").hasChildNodes)
    {
     $("reviewSheet").removeChild($("reviewSheet").lastChild);
    }

    $("reviewSheet").adopt(divMessage);         

   },

   onFailure:ajaxFailure,

   onException:ajaxFailure

 });

People commented that the problem was with how I assigned divMessage to reviewSheet . 人们评论说问题在于我如何将divMessage分配给reviewSheet I tried both adopt and appendChild but none works. 我试过adoptappendChild但没有一个工作。 A little help would be appreciated. 一点帮助将不胜感激。

divMessage.style.color="rgb:(105,105,105)";

应该

divMessage.style.color="rgb(105,105,105)";

Is the problem that you are calling the method hasChildNodes() on a jQuery object? 您是否在jQuery对象上调用方法hasChildNodes()的问题? I'm not sure what $("reviewSheet") is supposed to be, but wrapping a string in $() makes it a jQuery object which I don't believe will work with regular javascript methods. 我不确定$(“reviewSheet”)应该是什么,但是在$()中包装一个字符串会使它成为一个jQuery对象,我认为它不适用于常规的javascript方法。 If "reviewSheet" is the id of an element you could do something like 如果“reviewSheet”是元素的id,你可以做类似的事情

node = document.getElementById('reviewSheet');

then you could go into your while loop. 然后你可以进入你的while循环。

while (node.hasChildNodes()) {
 //the rest of your code here
}

Oh also you need to put the parenthesis after hasChildNodes() to return a boolean value. 哦,你还需要在hasChildNodes()后面加上括号来返回一个布尔值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未捕获的错误:NOT_FOUND_ERR:DOM异常8 - Uncaught Error: NOT_FOUND_ERR: DOM Exception 8 DOM-未捕获的错误:NOT_FOUND_ERR:带有RemoveChild的DOM异常8 - DOM - Uncaught Error: NOT_FOUND_ERR: DOM Exception 8 with RemoveChild 未捕获错误:NOT_FOUND_ERR:insertBefore上的DOM异常8 - Uncaught Error: NOT_FOUND_ERR: DOM Exception 8 on insertBefore 为什么chrome会在这里抛出“Uncaught Error:NOT_FOUND_ERR:DOM Exception 8”? - Why does chrome throw “Uncaught Error: NOT_FOUND_ERR: DOM Exception 8” here? 使用jquery.ajax()搜索数据库并获取“未捕获的错误:NOT_FOUND_ERR:DOM异常8” - Using jquery.ajax() to search db and getting “Uncaught Error: NOT_FOUND_ERR: DOM Exception 8” NOT_FOUND_ERR:DOM异常8-JavaScript - NOT_FOUND_ERR: DOM Exception 8 - javascript 关于此“ NOT_FOUND_ERR:Dom异常8”的一些信息使我感到困惑 - Something about this 'NOT_FOUND_ERR: Dom exception 8' confuses me 在使用jQuery解析JSON时,出现错误:NOT_FOUND_ERR:Chrome中的DOM异常8 - Getting Error: NOT_FOUND_ERR: DOM Exception 8 in Chrome when parsing JSON with jQuery 将弹出窗口绑定到Leaflet.js圈子:NOT_FOUND_ERR:DOM异常8 - Binding popup to Leaflet.js circle : NOT_FOUND_ERR: DOM Exception 8 使用plupload时,Ember中未捕获的NOT_FOUND_ERR:NOT_FOUND_ERR:DOMException 8 - Uncaught NOT_FOUND_ERR: NOT_FOUND_ERR: DOMException 8 in Ember while using plupload
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM