jquery - Call to JavaScript setTimeout not being called 10 times -


I have a JavaScript / jQuery code function that calls itself ten times if no data is available (fixed By web service call) I have implemented the code but logging inside the web service call indicates that it is only called 1 or 2 times what is the error in this code?

  function callIsDataReady (input) {var timer; Var calculation = 0; $ .jax ({url: "https://www.blah.com/services/TestsService.svc/IsDataReady"), type: "GET", contentType: "app / jason; charset = utf-8", data: Input (successfully): function (data) {ifTimeout (function (inputInner) {CallIsDataReady (inputInner); count ++; if (calculation == 10) {clear interval (timer); count = 0;}}, 1000); } And {console.log ("data returned - true returning"); // continue as data is ready View Var table = $ ("& lt;% = RadGrid1.ClientID%>") Get_masterTableView (); GetDataFromServer 0, TableViewGatePages ());}}, Error: Function (jqXHR, Text Ats, wrong count) {console.log ( "AJAX calls callIsDataReady failed"); Console.log (errThrown); }}); }  

Edit: It should try to do it ten times and then exit, should not go to GetDataFromServer. It should return an error how can I do this

setTimeout This means

  trigger the call once, and only once .  

Repeat the call to set a timeout from within your timeout callback if you want to work it out:

  function callIsDataReady (input) {var timer; Var calculation = 0; Function callWebService () {console.log ('calling service'); $ .jax ({url: "https://www.blah.com/services/TestsService.svc/IsDataReady"), type: "GET", contentType: "app / jason; charset = utf-8", data: Input console.log ('data =' + data); if (! Data) {if (count & lt; 10) {count ++; setTimeout () CallWebService, 1000);} else {count = 0;}} else {Console.log ("Data returned - true returning"); // Continue as data var is prepared tableview = $ find ("& lt;% = RadGrid1.ClientID% & Gt;") Get_masterTableView (); GetDataFromServer (0, tableView.get_pageSize ());}}, Error: function (jqXHR, textstats, incorrect trust) {console .log ("CallIsDataReady fails AJAX call"); Console.log (errThrown); }}); }; CallWebService (); }  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -