freequant | A C Library for Strategy Backtesting | Portfolio library
kandi X-RAY | freequant Summary
kandi X-RAY | freequant Summary
A C++ Library for Strategy Backtesting.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of freequant
freequant Key Features
freequant Examples and Code Snippets
Community Discussions
Trending Discussions on freequant
QUESTION
I am trying to check values from a database through sending the values by for loop in ajax request to php file, "each value in request" then the file return variable called "avl" if $data["avl"]==1
so it is available if not it is not available.
The problem is that I check a stream of values and they all must return 1
to continue my process, but the condition doesn't wait until the for loop ends to check. It checks the condition before the for loop starts, even the code is not like that. Ex: it does the condition in line 100 before for loop ends in line 50.
ANSWER
Answered 2019-Aug-23 at 10:33The ajax call you are doing inside the loop is asynchronous, this means that when the execution reaches the $.ajax[...]
line, it will run "in the background" while the normal execution continues through the loop.
What is most likely happening in your code is that the execution will reach the alert(avl_qty)
line before the ajax responses from the loop reach you. You can test this by letting the script run. You'll see that it will execute the alert("before avilability ajax")
, then alert(avl_qty)
and finally all the alert(JSON.stringify(data));
from the ajax requests.
To solve the issue you will have to wait for the async calls to finish, you can use async/await or even callbacks, here's an example.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install freequant
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page