When I use queryTask to call a function, say, function showResults() as below:
queryTask.execute(query, showResults);
function showResults (results) { ….}
One thing I am confused is that: usually when a function is called, the parameter that the function is going to use (e.g., results in this case) should be included inside the showResults(). Since queryTask called this function, it should be:
queryTask.execute(query, showResults(ABC); then this ABC will be passed into function showResults.
In the above example, there is nothing like showResults(ABC), just showResults. How can the function showResults (results) tell what kind of parameter is actually passed into it? Thanks!
Solved! Go to Solution.
Lei,
That is because the result of a queryTask is a deferred/promise. The results are added to the resulting function based on the deferred being resolved. You may want to learn more about dojos deferred and promise classes.
https://dojotoolkit.org/documentation/tutorials/1.10/promises/
Lei,
That is because the result of a queryTask is a deferred/promise. The results are added to the resulting function based on the deferred being resolved. You may want to learn more about dojos deferred and promise classes.
https://dojotoolkit.org/documentation/tutorials/1.10/promises/
Thanks a lot!
Lei,
Glad to help. Don't forget to mark this question as answered.