Hi everyone,
I'm kinda stuck over here. I hope someone can help me.
I have an input button on my page which has the onClick event and the onServerClick event. In the onClick event, the JavaScript code makes a call to a webservice. This webservice adds some records in a database table. After the webservice succesfully finishes, it response should be true.
The procedure goes like this:
function UpdateProduct(){...WebService.UpdateProduct(values, UpdateProduct_Callback);...}function UpdateProduct_Callback(response){return response;}
The onServerClick event refreshes the gridview I am using and selects the new record and its attributes.
The server side code executed by the onServerClick event should not be executed until the webservice is finished.
Is it possible to get the response in the UpdateProduct javascript function and return it? Like onClick="return UpdateProduct();"?
Thanks for your help!
No a callback is done after the WebService finishes on a seperate thread. Thats the whole point of a callBack, you dont have to wait for the method to finish executing. If you want to get the return value, wait for your method to finish, instead of using a callback.
Thanks for your quick reply.
Is there any other way to wait on the return value of the webservice through JavaScript without the callback? Or is it better do do it from the server side code?
You have to do it server side, JS only supports callbacks on webservice calls.
Thanks for your help. I will do it through server side code.
No comments:
Post a Comment