javascript - Implementing recursive ajax call and stop it at one condition -


Looking for hours and trying, but as a newbie in things of AJAX, whatever I want, I have failed to get it. Here's one thing: 1. I have a page that takes the data of current date from DB, so I recite the Ajax function with setTimeOut () some 10 seconds I am calling the updated DB Records 2. I have failed here. I have a date picker, so as soon as the user selects a previous date from the jquery picker, I should stop the current Ajax process and get the data of that particular date Do to And I do not want to call it again because there is no change in previous data

code for recursive thing

  function (Selected date) {$ (document) .ready (function () {$ ("# (" Trit "). $ (.); $ ($ GetDataservlet), {'selectedDate': selectedDate}, function (responseJson) { If (responseJson! = Null) {$ ("# datatable"). ("Tr: Gt (0)"). Remove (); var table 1 = $ ("# datatable"); $ .Ee (Reaction Jason, Function (key, value) {var rowNew = $ ("<">    & Lt; / Td> & Lt; TD & gt; & Lt; / Td> & Lt; Td> & Lt; / Td> & Lt; TD & gt; & Lt; / Td> & Lt; / Tr & gt; "); RowNew Children (). Eq (0) .text (value ['first']); line new child (). Eq (1) .text (value ['two']); line new child ). Eq (2) .text (value ['three']); .rowNew.children () eq (3) .text (value ['four']); rowNew.children () eq (4) .text (Value ['five']); rowNew.appendTo (table1);});} SetTimeout (Macaul, 10000, selected);}; $ ("# Divtable") Show ();}};} MacLean The current date ());  

The first time the MacLeal (current date) will be called and for every 10 setTimeout () will be recurring

of the luxury calendar The code is

  $ (function () {$ ("#interpret input"). While // is to stop the current recursive call. When the user selects the current date, then it should be repeated again.}, ShowOn: "button", buttonImage: "cal.gif", the button image only: True, date format: "yy-mm-dd"}}};  

Can someone help me on this? Sorry, despite trying several times I am unable to format the code in question.

Just create a boolean flag to indicate that the current date is selected:

  var someFlag = true, timeout = null; Function Meal (SelectedDate) {if (someFlag == true) {$ ("# divtable") Hide (); $ .get ('getdataservlet', {'selectedDate': selectedDate}, function (responseJson) {if ((!! hackant date (selected) || someFlag == true) & amp; amp; amp; response! Jason! = Null Extract (); var table1 = $ ("#datatable"); $ .each (responseJessen, function (key, value) {var rowNew = $ ($ ("#" ("tr: gt (0)") "& Lt; tr & gt;       gt; & lt; TD & gt; & lt; / TD & gt; & lt; / tr & gt;); rowNew.children () Eq (0) .text (value ['first']); line new. Child (). Eq (1) .text (value ['two']); line new. (Hair) () .Eq (2) .text (m (['Three']); Rown New child (). Eq (3) .text (value ['four']); Line new children (.) Eq (4) .text (value ['five'] ); $ ("# Divtable") show;)} $ $ (document) .ready (function ()); $ (document) {Macaul (current date ());});  

Also implement the function is that the custodian gives the boolean value if the given date is current. $ {Function () {$ ("function") {$ ("# dateinput"). ({On: function (date) {clear timeliness}, if (hacked date (date)) {someFlag = true ; Make call (date);} and {someFlag = false;}}, showOn: "button", button image: "Cal.gif", button image only: true, date format: "yy-mm-dd"} }}};


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -