How to loop a public method on ASP.NET C# using Javascript? -


i have following method:

//bolo stands on lookout [webmethod] public void loadbolos() {     list<string> bolos;      //if not loaded before     if (viewstate["bolos"] == null)     {         list<string> bolos = getbolos();          viewstate["bolos"] = bolos;         viewstate["index"] = 0;     }      else     {         bolos = (list<string>)viewstate["bolos"];     }      int index = viewstate["index"] != null ? (int)viewstate["index"] : 0;      if (bolos.count > 0)     {         imgbolo.imageurl = bolos[index];         index++;         index = index >= bolos.count ? 0 : index;     }      viewstate["index"] = index; } 

and here js file on aspx

window.onload = function () {     bolotimer(); }  function bolotimer() {     boloswitch();      bolotimer = settimeout     (         function ()         {             bolotimer = null;             bolotimer();         },           10000     ); }  function boloswitch() {     $.ajax     (         {             type: 'post',             url: 'nameofpage.aspx/loadbolos"',             data: '{ }',             contenttype: 'application/json; charset=utf-8',             datatype: 'json',             success:             function (msg)             {                 console.log("success");             }         }     ); } 

i need loop method every 10 seconds, can refresh image on aspx page.

however, though put breakpoints on js , cs, execute function, never reaches webmethod.

am missing something?


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -