Ticket #3521 (closed bug)
remove() fails with IE & ajax
| Reported by: | arobinson | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 1.3 |
| Component: | core | Version: | 1.2.6 |
| Keywords: | Cc: | arobinson, flesler | |
| Blocking: | Blocked by: |
Description
When trying to manipulate the xhr responseXML when complete, I get errors in IE7 in jQuery 1.2.6.
The error happens at line 666 (go figure):
data: function( elem, name, data ) {
elem = elem == window ?
windowData : elem;
var id = elem[ expando ];
Compute a unique ID for the element if ( !id )
id = elem[ expando ] = ++uuid;
The code I am using (xml is the xhr.responeXML): var $scripts = $('script', xml).remove();
If I remove the call to "remove()" the error goes away.
Is there a way around this?
Change History
comment:1 Changed 5 years ago by flesler
- Cc arobinson, flesler added
- need changed from Review to Test Case
comment:2 Changed 5 years ago by n_2
I have this same problem, works fine in ff, fails in ie at line 666. (loading xml from a string, rather than ajax call)
Here is a test case that works in ff, fails in ie. (latest version of jquery, 1.26)
<script type="text/javascript">
//Xml Parser object
var xmlParser = {
xmlDoc : null,
//Loads the xml string into a xml doc
loadFromDb : function(xmlString) {
if(window.ActiveXObject) { //ie
this.xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
this.xmlDoc.async="false";
this.xmlDoc.loadXML(xmlString);
}
else { //ff/opera
var parser = new DOMParser();
this.xmlDoc = parser.parseFromString(xmlString,"text/xml");
}
},
toString : function() {
if (window.ActiveXObject)
return this.xmlDoc.xml;
else
return (new XMLSerializer()).serializeToString(this.xmlDoc);
},
deleteTest : function() {
$(this.xmlDoc).find("gd > cd > uid").remove();
}
};
//Our test xml string
var xml = "<gd><cd><uid>0</uid><tm>0</tm><w>0</w><h>0</h></cd></gd>";
//Load our xml up
xmlParser.loadFromDb(xml);
//And try and delete the uid node
xmlParser.deleteTest();
//Works fine in ff, fails in ie 7, "Object doesn't support this property or method.
//Line 666 of jquery: id = elem[ expando ] = ++uuid;
alert(xmlParser.toString());
</script>
comment:3 Changed 5 years ago by MaRsuPiLaMi
Another much simplier test-case. I provided a cross browser implementation so you can test it quite easyly.
<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>JQuery-Testen</title>
<script text="JavaScript" type="text/javascript" src="jquery-1.2.6.js"></script>
<script text="JavaScript" type="text/javascript">
function getDomFromXml(xml) {
if (typeof ActiveXObject != 'undefined') {
var dom = new ActiveXObject("Microsoft.XMLDOM");
dom.async = false;
dom.loadXML(xml);
} else {
parser = new DOMParser();
dom = parser.parseFromString(xml, "text/xml");
}
return dom;
}
function getXmlFromDom(xmlDom) {
if (typeof ActiveXObject != 'undefined') {
return xmlDom.xml;
} else {
return (new XMLSerializer()).serializeToString(xmlDom);
};
}
$(document).ready(function(){
// get 2 doms
dom = getDomFromXml("<container><repr type=\"text\"></repr></container>");
anotherDom = getDomFromXml("<container><blubb type=\"text\">bla</blubb></container>");
repr = $("repr",dom);
blubb = $("blubb",anotherDom);
//append the <blubb> element to the <repr> element
repr.append(blubb);
alert(getXmlFromDom(dom));
// should remove the appended <blubb> element
repr.find("*").remove();
// ie never reach this line
alert(getXmlFromDom(dom));
});
</script>
</head><body></body></html>
comment:4 Changed 3 years ago by snover
- Status changed from new to pending
This ticket has been marked as missing a test case. In an effort to reduce the number of outstanding tickets in the bug tracker, it will be closed automatically in 30 days. In order to prevent this from happening, please provide a working test case. If a test case has already been provided and our records are wrong, please respond to the ticket so that it can be fixed. Thank you!
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Can you make a test case to reproduce the problem ?