This is an excellent and specific article on this subject.
The following code works for me.
I have a page that processes an excel file asynchronously; during processing, the EsperarFinDelCargue () function will query the PageMethod method called CargueFinalizo () every second to check if processing has completed. When processing is complete, a redirection occurs.
OnCallFinalizoComplete is a callback function to call PageMethod, so you need to use the resulting object.
<script type="text/javascript"> function EsperarFinDelCargue() { PageMethods.CargueFinalizo(OnCallFinalizoComplete); if($('#<%=this.hidCargueFinalizado.ClientID %>').val() == "SI") { document.location = "CargarPanelHCP.aspx"; } else { var t=setTimeout("EsperarFinDelCargue()",1000); } } function OnCallFinalizoComplete(result,contexto,CargueFinalizo) { $('#<%=this.hidCargueFinalizado.ClientID %>').val(result); } </script>
And here is the PageMethod code in aspx:
[System.Web.Services.WebMethod] public static string CargueFinalizo() {
daniloquio
source share