Since we haven’t heard from you for some days, I am closing you post by marking bruce and Anup’s reply as answer. If their reply did not resolve your problem, please feel free to unmark the answer. If you have further issue but different than the original
one in this thread, please open a new question. Thanks for your cooperation.
Thanks,
Yanping Wang
Please mark the replies as answers if they help or unmark if not.
Feedback to us
yani
Member
104 Points
126 Posts
problem with var 'undefined' after defineding it
Dec 09, 2012 03:51 PM|LINK
hello
on Jquery last vartion
on keyUp event i check if a global var is === 'undefined'
and if so i fill it from XML data...
than i try agan --->> but still is umdefine!
ONLY after the second keyUp event the Var is define!
$(document).ready(function () { var __XML; $('.target').keyup(function () { if (typeof __XML === 'undefined') GatXmlData(); pupolateWithData(__XML); // still undifine }); function GatXmlData() { $.ajax({ type: "GET", url: "DAL/XML_xxoo.xml", dataType: "xml", success: function (xml) { __XML = xml; } }); }bruce (sqlwo...
All-Star
36644 Points
5432 Posts
Re: problem with var 'undefined' after defineding it
Dec 09, 2012 05:42 PM|LINK
the a in ajax means async, you are calling populate before it returns. look at the deferred object. or just call it from the success lambda.
asteranup
All-Star
30184 Points
4906 Posts
Re: problem with var 'undefined' after defineding it
Dec 10, 2012 03:59 AM|LINK
Hi,
Either set async:false in the ajax call. Or change the code loke below-
$(document).ready(function () { var __XML; $('.target').keyup(function () { if (typeof __XML === 'undefined') GatXmlData(); }); function GatXmlData() { $.ajax({ type: "GET", url: "DAL/XML_xxoo.xml", dataType: "xml", success: function (xml) { __XML = xml; pupolateWithData(__XML); } }); }Anup Das Gupta
Mark as Answer if you feel so. Visit My Blog
Yanping Wang...
Star
14859 Points
1525 Posts
Microsoft
Re: problem with var 'undefined' after defineding it
Dec 21, 2012 06:45 AM|LINK
Hi yani,
Since we haven’t heard from you for some days, I am closing you post by marking bruce and Anup’s reply as answer. If their reply did not resolve your problem, please feel free to unmark the answer. If you have further issue but different than the original one in this thread, please open a new question. Thanks for your cooperation.
Thanks,
Yanping Wang
Feedback to us
Develop and promote your apps in Windows Store