Saturday, March 24, 2012

Trouble canceling an Ajax webservice

I have been searching how to cancel a webservice request in javascript and the standard solution does not seem to work for me. I call the webservice like this.

_request = ClientServices.GetPolyListings(myPoints, SearchComplete, SearchFailed);

_request seems to always be undefined after I do this.. I checked the value during through the debugger and even tried sleeping the thread in the webservice to postpone it for testing. Nothing seems to work. I have this code which never executes because its undefined.

if(_request)

_request.get_executor().abort();

Try with:

_request = ClientServices._staticInstance.GetPolyListings(myPoints, SearchComplete, SearchFailed);
Check:
http://geekswithblogs.net/rashid/archive/2007/07/14/Cancel-a-Web-Service-Call-in-Asp.net-Ajax.aspx

Thank you works great. Do not know how I forgot the _staticInstance because I am pretty sure I looked at that site already. Thanks Solved.


Would you pls mark it as answer.

No comments:

Post a Comment