Which code segment should you use?

You are developing an application that consumes an external web service that returns the latest stock rate.
The application has two methods:
The getResults() method makes an AJAX web service request
The ShowRate() method displays the stock rate from the web service response
You need to ensure that the ShowRate() method always displays the latest stock rate.
Which code segment should you use?

You are developing an application that consumes an external web service that returns the latest stock rate.
The application has two methods:
The getResults() method makes an AJAX web service request
The ShowRate() method displays the stock rate from the web service response
You need to ensure that the ShowRate() method always displays the latest stock rate.
Which code segment should you use?

A.

B.

C.

D.



Leave a Reply 4

Your email address will not be published. Required fields are marked *


stijn

stijn

can someone explain the answer D? why synchronous call?

author should review syntax.

Ivan

Ivan

Stijn, synchronous calling is necessary because the AJAX request needs to wait to a result that is displayed subsequently by the ShowRate() function.

abdullah tahan

abdullah tahan

Cache should be false as the stock rate should always be the most recent, hence the correct answer.

oneskyp

oneskyp

Well, I think the correct answer is D .. It must be synchronous since the method ShowRate is not being calling inside of the ajax success function… which means that it does not have a way to determine if the data was updated.. for that reason.. the call must be synchronous so as to way for the response and then use the showRate method with the data updated. Hope … it makes sense for you