There are some postings about getting the returned value of the get-call. But my problem is still there.
My source
...
$.get("list.svc/XmlTestService", function (XmlData) { console.log(XmlData); }, "xml");
...
alert($Loc['Name']);
...
I get an XML-Document which is correct at the console. Normaly I have to proceed with the Xml to do something. This will be done in a separate function like this:
function GetOutXml (XmlData) {
...
return { 'Name': ValueName }
}
Now I need to close my gap between my get-call and the alert. I tried some different things but without success. One way was something like this:
...
var $Xml = null;
$.get("list.svc/XmlTestService", function (XmlData) { $Xml = XmlData; }, "xml");
var $Loc = GetOutXml($Xml);
...
But without success. I´m new with the World of JS (only basics). Normaly I build my source with an functional architecture.
How can I do this right?
Update: Okay...I solved my problem in a other way after reading a lot. Because to do every thing in anonymous function is not my way of thinking and it´s hard to read and follow after time.
So what I did:
...
var $Xml = null;
$.ajax({type:'GET',url:"list.svc/XmlTestService",success: function(Data) { $Xml = Data;},dataType:'xml',async:false});
...
var $Loc = GetOutXml($Xml);
...
The important step is to do the job with the ajax-command because of the posibility to set async to false so it is sync.
Thanks for helping me.