Function that returns the value from updateData

updataData() is asynchronous.  

Here’s a pattern that I use and you should be able to adopt it for your needs.

var deferred = $.Deferred();<br>...<br>$.when(myModel.updateData())&nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp;.done(function () {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Success &nbsp; &nbsp; &nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;deferred.resolve(); &nbsp; &nbsp; &nbsp;<br>&nbsp; &nbsp;})<br>&nbsp; &nbsp;.fail(function () {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Error<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;deferred.reject();<br>&nbsp;}); ...<br>return deferred.promise();