0

I want to use ajax in jquery to get data for my page...

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

the data i get in response from this url can be in xml format or java script arrays(whichever i choose)

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> 

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')); 

So when i get the data i want to store it in a drop down box.(using ajax)

Note I can get either xml OR javascript arrays as the returned data, not both together.

1
  • Please format your code via the Code button. Commented Jun 4, 2011 at 15:22

4 Answers 4

1

You can make an ajax call along with parameters like this:

var paramsData = "t=abcde&token=h34jk3"; $.ajax({ type: "GET", url: "dataengine.aspx", data: paramsData, dataType: "xml", success: function(xml){ //process xml from server } }); 
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks....this was very helpful...although it didnt work bcoz i was gettin the data from an external source to be ajaxed..but still..this will come in use for another part of my project...thanks again
0

I would suggest you to get the data in JSON format, as Json comes natively to javascript and it much easliy manipulated using javascript as compared to XML. The easiest way i can see to work on your problem is to store all your data whether xml or json & put it inside a hidden div and then use jQuery to populate that data in a drop down box. Here is an amazing jquery plugin with example that should ease your work http://plugins.jquery.com/project/jqueryclientdb

Comments

0

Just parse it. I"m not sure if this will work, but it might:

xml = ... region = new Array(); $(xml).find('Region').each(function() { region.push(new Array($(this).attr('SubCode'), $(this).attr('RCode')); }); 

Comments

0

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...

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.