Skip to content Skip to sidebar Skip to footer

Trigger/prevent Page Event By Using Asynchronous Webmethod Return Value In Javascript

I use a webmethod to identify whether the user can 'Delete a record'. Here is the JavaScript code before adding this access control. $('.apply-delete-msg').live('click', function()

Solution 1:

The Web Service call is asynchronous and will return a result after you have returned from the click message. Therefore you always need to return false from the click method and re-design your page, so that the action that would have normally taken place after client side click (and true returned) to be performed after web service method returns. It would also be good to have a "Please wait..." message, while waiting for the call to complete.

Solution 2:

There is two ways to do it :

  • do the comment A code into the boolRes==true block
  • create a callback which contains the code of comment A and call this callback in the boolRes==true block

Post a Comment for "Trigger/prevent Page Event By Using Asynchronous Webmethod Return Value In Javascript"