I have created a webservice and want to call it from javascript , for this I have registered ServiceReference in my page’s script manager, and called webservice using namespace.
My problem is that I want to wait until response from webservice received.
For this I was trying to using setInterval but that does not work.
Any other way to achieve this?
More Details are below:
In Javascript If you write a function to call WebService you have to pass it a method signature that will be called after webservice sends response.
e.g.
var IsResponseReceived;
function GetSomethingFromWebService()
{
IsResponseReceived = 'No';
Namespace.WebServiceClass.GetMeSomething(parameter1,SuccessResponseReceiver);
alert(webServiceResponse);
}
function SuccessResponseReceiver(parameter1,parameter2)
{
IsResponseReceived = 'Yes';
}
In the above code my alert gives me ‘No’ everytime. I want to write someline inbetween alert and webservice call that should let me wait until I get response.
Am I Clear now?
If you consider using pure JavaScript (pretty unusual these days), consider this code
If you consider using jQuery (this one of the popular JavaScript framework around), its easy: