I am new to jQuery and I am using ajax request to get an xml as response,
$.get('testurl',pars,function(data){ xml = data; $(xml).find('element').each(function(i,item){ if(($(this).attr('id'))!= undefined){ tab_str += '<tr><td>'id'</td><td>'+$(this).attr('id')+'</td></tr>'; } }); });//get
In the above code I get the xml back as expected. The only problem is I need to completely construct my table before the rest of the code executes. So I decided to use the $.ajax function with async false. But this time I am not getting anything back. (I check the firebug console, it shows the complete xml in the response section)
var xml = ( $.ajax({ type: 'GET', url: 'testurl', data: pars, aysnc:false }).responseText);
In the code above the var xml is empty. Why is this? am I doing something wrong? Please help. Thanks in advance.
If you copied-n-pasted the code in your example, you have
asyncmisspelledaysnc. Without that option, it will run asynchronously.