asp.net - Using timer with AJAX request -


i'm new stuff, so, should pretty easy thing find answer to. have 2 pages, 1 using ajax make request second page. second page respond sum of 2 numbers.

my problem is, need response sent in 5 seconds during value of button changed so, i'm setting timer postpone response, results without delays.

here pages:

page1:

<input type="button" name="btndorequest" value="perform calculation"   onclick="performcalculation(this);" />  <script type="text/javascript">     function performcalculation(sender) {         $(sender).val("working - please wait...");         $.get("calculations.aspx", function (data, textstatus) {             $(sender).val("perform calculation");             alert(data);         });     } </script> </asp:content> 

page2:

<div>    <%     int = 45;     int j = 45;     system.timers.timer timer = new system.timers.timer();     timer.interval = 5000;     timer.start();      response.write(i + j);    %> </div> 

any suggestions on i'm doing wrong?

thank's

you can using javascript replacing following 2 lines of code

$(sender).val("perform calculation"); alert(data); 

with

 settimeout(function(){ $(sender).val("perform calculation"); alert(data); }, 5000); 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -