如何在jquery中使用ajax获取xml数据? [英] How to get xml data using ajax in jquery?
问题描述
我想在jquery中使用Ajax来获取我页面的数据...
I want to use ajax in jquery to get data for my page...
问题是我调用的url有一些查询字符串要与之一起发送...
The problem is that the url which i call has some query strings to be sent along with it...
例如:我要求获取数据的网址是:-
for example: the url which i call for getting data is:-
http://mysite.in.dataengine.aspx?t = abcde& token = h34jk3& f = xml
我从此url获得的数据可以是xml格式或java脚本数组(以我选择的为准)
the data i get in response from this url can be in xml format or java script arrays(whichever i choose)
例如... xml将如下所示:-
for eg...the xml wil look like this:-
<root version="1.0">
<Regions>
<Region SubCode="MWEST" RCode="west"/>
<Region SubCode="MCENT" RCode="north"/>
<Region SubCode="THAN" RCode="south"/>
</Regions>
</root>
和javascript数组如下所示:-
and the javascript array would look like this :-
Region = new Array();
Region.push(new Array('MWEST', 'west'));
Region.push(new Array('MCENT', 'north' ));
Region.push(new Array('THAN', 'south'));
因此,当我获取数据时,我想将其存储在一个下拉框中.(使用ajax)
So when i get the data i want to store it in a drop down box.(using ajax)
注意,我可以将xml或javascript数组作为返回数据,而不是两者都作为返回数据.
Note I can get either xml OR javascript arrays as the returned data, not both together.
推荐答案
感谢您的帮助...但是我找到了解决方法.就像我说的那样,我得到了xml或javascript的回报.数组...所以..我正在使用JavaScript数组..并在jquery * ($.getScript) *中使用一个函数,该函数通过ajax获取外部javascript代码...因此,我正在获取现在我所有的数据都通过jquery中的ajax ...
Thanks for your help guys...but i have found the solution....Like i said...that i get in return either xml or javascript array...So..i'm using javascript arrays.. and using a function in jquery*($.getScript)* which fetches an external javascript code via ajax...Thus i am getting all my data now through ajax in jquery...
这篇关于如何在jquery中使用ajax获取xml数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!