In jquery 1.4.2 i was able to select xml residing in my html page by doing the following:
在jquery 1.4.2中,我可以通过执行以下操作选择驻留在我的html页面中的xml:
var xmlSettings = $("#xmlSettings")[0];
this is the same as:
这与以下相同:
document.getElementById("xmlSettings"); //this still works fine
In jquery 1.6.1 xmlSettings is undefined. all i did was upgrade my jquery from 1.4.2 to 1.6.1 and now this is not working.
在jquery 1.6.1中,xmlSettings未定义。我所做的只是将我的jquery从1.4.2升级到1.6.1,现在这不起作用。
is there a different selection that i need to do, or do i need to add a plugin?
我需要做一个不同的选择,还是需要添加一个插件?
xml in Html page:
Html页面中的xml:
<xml id="xmlSettings">
<items>
<item name="Test1">Test data 1</item>
<item name="Test2">Test data 2</item>
<item name="Test3">Test data 3</item>
</items>
</xml>
thanks in advance,
提前致谢,
[Resolved] Thanks to Felix Kling
[已解决]感谢Felix Kling
the problem seems to be one of the following:
问题似乎是以下之一:
1) IE9 is not rendering IE8 Standards mode properly. I just recently upgraded to IE9 but my app still needs to run in IE8 Standard Mode therefore I've forced it in IIS to render in IE8 using X-UA-Compatible IE=8
1)IE9未正确呈现IE8标准模式。我刚刚升级到IE9,但我的应用程序仍然需要在IE8标准模式下运行,因此我强制它在IIS中使用X-UA兼容IE = 8在IE8中渲染
2) i also updated my jquery file from 1.4.2 to 1.6.1
2)我还将我的jquery文件从1.4.2更新到1.6.1
but it could be a combination of these things i'm not really sure anyway using normal document.getElementById("xmlSettings");
still works fine so in the mean time i'll use that but very bizarre issue. i wouldn’t be surprised if it's an IE9 issue. Or maybe i'll remain on jquery 1.4.2 for now.
但它可能是这些东西的组合,我不确定无论如何使用普通的document.getElementById(“xmlSettings”);仍然工作正常,所以在同一时间我会使用但非常奇怪的问题。如果它是IE9问题,我不会感到惊讶。或者也许我现在仍然会继续使用jquery 1.4.2。
3 个解决方案
#1
1
This is the real reason it's not working: a regression in jQuery 1.4.2.
这是它不起作用的真正原因:jQuery 1.4.2中的回归。
#2
0
You probably don't need the [0] because an id is a singular value and doesn't return an object list like finding a class would.
您可能不需要[0],因为id是一个奇异值,并且不会像查找类那样返回对象列表。
#3
0
I've answered my own question as suggested by Arend
我按照Arend的建议回答了我自己的问题
[Resolved] Thanks to Felix Kling
[已解决]感谢Felix Kling
the problem seems to be one of the following:
问题似乎是以下之一:
1) IE9 is not rendering IE8 Standards mode properly. I just recently upgraded to IE9 but my app still needs to run in IE8 Standard Mode therefore I've forced it in IIS to render in IE8 using X-UA-Compatible IE=8. Also another thing about X-UA-Compatible rather use IE=EmulateIE8 not IE=8. But still even when you use IE=EmulateIE8 it still does not play nicely with jquery 1.6.1. Therefore its better to use IE9 standard mode which works fine, so busy converting code to be standard be compliant anyway better in the long run.
1)IE9未正确呈现IE8标准模式。我刚刚升级到IE9,但我的应用程序仍然需要在IE8标准模式下运行,因此我强制它在IIS中使用X-UA-Compatible IE = 8在IE8中渲染。关于X-UA-Compatible的另一件事是使用IE = EmulateIE8而不是IE = 8。但即使你使用IE = EmulateIE8,它仍然不能与jquery 1.6.1很好地配合。因此最好使用工作正常的IE9标准模式,因此从长远来看,繁忙的转换代码是标准的。
2) i also updated my jquery file from 1.4.2 to 1.6.1
2)我还将我的jquery文件从1.4.2更新到1.6.1
but it could be a combination of these things i'm not really sure anyway using normal document.getElementById("xmlSettings");
still works fine so in the mean time i'll use that but very bizarre issue. i wouldn’t be surprised if it's an IE9 issue. Or maybe i'll remain on jquery 1.4.2 for now.
但它可能是这些东西的组合,我不确定无论如何使用普通的document.getElementById(“xmlSettings”);仍然工作正常,所以在同一时间我会使用但非常奇怪的问题。如果它是IE9问题,我不会感到惊讶。或者也许我现在仍然会继续使用jquery 1.4.2。
#1
1
This is the real reason it's not working: a regression in jQuery 1.4.2.
这是它不起作用的真正原因:jQuery 1.4.2中的回归。
#2
0
You probably don't need the [0] because an id is a singular value and doesn't return an object list like finding a class would.
您可能不需要[0],因为id是一个奇异值,并且不会像查找类那样返回对象列表。
#3
0
I've answered my own question as suggested by Arend
我按照Arend的建议回答了我自己的问题
[Resolved] Thanks to Felix Kling
[已解决]感谢Felix Kling
the problem seems to be one of the following:
问题似乎是以下之一:
1) IE9 is not rendering IE8 Standards mode properly. I just recently upgraded to IE9 but my app still needs to run in IE8 Standard Mode therefore I've forced it in IIS to render in IE8 using X-UA-Compatible IE=8. Also another thing about X-UA-Compatible rather use IE=EmulateIE8 not IE=8. But still even when you use IE=EmulateIE8 it still does not play nicely with jquery 1.6.1. Therefore its better to use IE9 standard mode which works fine, so busy converting code to be standard be compliant anyway better in the long run.
1)IE9未正确呈现IE8标准模式。我刚刚升级到IE9,但我的应用程序仍然需要在IE8标准模式下运行,因此我强制它在IIS中使用X-UA-Compatible IE = 8在IE8中渲染。关于X-UA-Compatible的另一件事是使用IE = EmulateIE8而不是IE = 8。但即使你使用IE = EmulateIE8,它仍然不能与jquery 1.6.1很好地配合。因此最好使用工作正常的IE9标准模式,因此从长远来看,繁忙的转换代码是标准的。
2) i also updated my jquery file from 1.4.2 to 1.6.1
2)我还将我的jquery文件从1.4.2更新到1.6.1
but it could be a combination of these things i'm not really sure anyway using normal document.getElementById("xmlSettings");
still works fine so in the mean time i'll use that but very bizarre issue. i wouldn’t be surprised if it's an IE9 issue. Or maybe i'll remain on jquery 1.4.2 for now.
但它可能是这些东西的组合,我不确定无论如何使用普通的document.getElementById(“xmlSettings”);仍然工作正常,所以在同一时间我会使用但非常奇怪的问题。如果它是IE9问题,我不会感到惊讶。或者也许我现在仍然会继续使用jquery 1.4.2。