jQuery get(xml) returns #document

Roginonoiva

New Member
I'm quite new to JavaScript. Don't know if my question was here before, but I could not find it.I'm trying to get data from a server and store it into a variable (therefor the synchronous call). On the one hand a .json file and on the other hand a .xml file. I'm using jquery to do this. My code looks like this.\[code\]this.readData= http://stackoverflow.com/questions/14540471/function(pDatatype){ $.ajaxSetup({async:false}); var data; if(pDatatype=="json") { $.get('jsonData.json', function(resultJSON){ data=http://stackoverflow.com/questions/14540471/resultJSON}) } else (pDatatype=="xml") { $.get('xmlData.xml', function(resultXML){ data=http://stackoverflow.com/questions/14540471/resultXML;}) } return data;};\[/code\]This works quite well. But it's not perfect.I call them this way:\[code\]var XMLdata = http://stackoverflow.com/questions/14540471/someClass.readData("dataName.xml");var JSONdata = http://stackoverflow.com/questions/14540471/someClass.readData("dataName.json");alert(XMLdata +"\n"+ JSONdata);\[/code\]And get the following Message: [object Document] [object Object"]. As I had a look into the debugger, the XML-object was huge (had a lot of extra stuff besides the actual data) whereas the JSON-object only had the actual data.What kind of special object is the XML-object/document? Is there an easy way to convert it into a simple structure like the JSON-object?Thanks for help and excuses for my bad english ;)
 
Back
Top