Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 82002

Synchronous vs Asynchronous when using Web-API on web-resource

$
0
0

When using the new Web-API for on-premise 2016 , the documentation I have seen indicates to make the call asynchronous for the XMLHTTPRequest.

However, making it asynchronous seems to not work in getting expected results back on time. 

For example I am initializing a variable to equal a return value that comes from an asynchronous web-api call.  The variable becomes undefined. However, setting a breakpoint in the web-api call itself, the expected value is returned. It appears that between the line declaring the variable and iterations of checking the readystate and status, the javascript continues on before the web-api request is truly finished.  This makes sense being asynchronous but it results in bad data.  If I make the call synchronous without a check on readystate and status the data expected returns and populates the variable as expected.

This has happened on other web-api calls that we are putting together.  Any ideas ?  Would prefer to use asynchronous as that is the recommendation but it does not seem to work as expected.


Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images