Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
rsynnest758y@Flarp it's a for loop with one ajax call per iteration, and the ajax return appends to a global array. I want to use the global array in another function, I can probably do it with callbacks but will most likely just do it in PHP since it doesn't need to be client side
-
mhall2748yJavaScript is mostly single threaded and blocking, except for I/O and UI stuff that has been moved out of the mainthread
But God help us if I/O like Ajax weren't async. The web would truly suck ...
Have you looked at promises and promises.all()? Or is jQuery.when() available?
You could easily create a promise which waits for all Ajax calls to complete before executing.
I know you said it doesn't need to be done in the client side this time, but next time it might ... -
@rsynnest like seriously? Imagine the world with synchronous ajax. Its not the world lenon asked us to dream about.
Here for loop itself is sync. Its the call that's async.
Look into promises. They are promising. -
rsynnest758y@mhall oh async processing is fantastic, computing would be nightmarish without it and the web would suck without ajax, I just had to rant before diving back in. promise.all() is definitely the answer, though I will prob move it backend for other reasons.
-
cahva10158y@d4ng3r0u5 I started with async.js but with native promises it has became obsolete IMO
Related Rants
Dear javascript, you think you're sooooo fucking special. You just HAD to be asynchronous everywhere, losing all connections to natural sequential human thinking. I just want to work with the result of A GOD DAMN FOR LOOP you ASYNC FUCK.
undefined
javascript
fuck