Skip to main content
12 events
when toggle format what by license comment
Jan 18, 2016 at 8:23 vote accept Orange Juice Jones
Jan 15, 2016 at 16:16 comment added Gilgamesh I simply wrote code that corrected the very minor error you had in your post. In theory doing a bunch of async operations won't cause issues. however once you want to handle responses to async operations you will have to write code that deals with it. This is larger topic and there's lots of information on how to do async things with javascript, for example Promises are one way that this is often handled.
Jan 15, 2016 at 16:07 comment added Orange Juice Jones When you say cascading async functions work, my example doesn't demonstrate it well. If I had loop in a success method which triggered another function that also contained an async method, will this not cause issues? I done this previously, and had to use an array in the 1st loop which fed into the 2nd async function.
Jan 15, 2016 at 15:32 comment added Gilgamesh My methodology to test was to create the method i posted above and then run the btnSubmit_OnClientClick() method from your question, the output for me is correct and it logs "completed main code" then then the log messages for items 1-3 being created.
Jan 15, 2016 at 15:29 comment added Orange Juice Jones I'm attempting to log the items created to the console from within the success callback function. This is where the error occurs.
Jan 15, 2016 at 15:19 comment added Gilgamesh I changed the name of the list in my example so that might be the problem you have.
Jan 15, 2016 at 15:15 comment added Orange Juice Jones I've tried the code as Gilgamesh suggested and receive an error in the success method - 'oListItem' is undefined -
Jan 15, 2016 at 15:04 comment added Vamsi K K Yes, that answered the question! Thanks. Up Vote for you!
Jan 15, 2016 at 14:49 history edited Gilgamesh CC BY-SA 3.0
Added an example.
Jan 15, 2016 at 14:28 comment added Vamsi K K Orange Juice confirmed that the items are created as expected which proves that async works in loop. I think his question was why only the last item id is printed when all items are created correctly! I don't think you answered his actual question! I think you need to be clear about 'try using var oListItem instead and then passing the reference to the item into your success method in some manner.'
Jan 15, 2016 at 13:58 history edited Robert Lindgren CC BY-SA 3.0
added 6 characters in body
Jan 15, 2016 at 13:55 history answered Gilgamesh CC BY-SA 3.0