javascript - Ajax function stops automatically working after a "Failed to load resources" error -


i'm using ajax update info in page. used $.when $.then functions identify when call on , should activate timer.

the issue here when call gets "failed load resources" error (no matter 1 of them), stop working @ middle of execution, , without resetting timer.

this code:

function updatecodgw() {     if(codgw_running == false && session_ended == false)     {         codgw_running = true;         $.when($.ajax({             url: 'the_url',             data: {ajax: 'gwonline'},             type: 'post',             datatype:'json',             success: function(sinfo) {                 if(sinfo.session !== false)                 {                     session_id = sinfo.session;                     var gwstatus = $(codgwid);                     sinfo.isonline ? codgw_offline = 0 : ++codgw_offline;                     if(!sinfo.error && sinfo.isonlinestr !== codgw_old && (sinfo.isonline || codgw_offline >= 3))                     {                         gwstatus.html(sinfo.isonlinestr);                         codgw_old = sinfo.isonlinestr;                     }                 }                 else                     session_ended = true;             },             failure: function() {              }         })).then(function() { if(session_ended == false) { codgw_running = false; updatecodgwtimer(); } });     } } 

i don't know did wrong code won't handle such errors.


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -