JavaScript Offline Detection - function not available -


i have troubles understanding javascript.

when making ajax request , user has no connection main server, connection class called function notify.

so when open page, disable internet , click button, fires request, alert have no internet connection anymore.

as good. function "backup" not called. error that: typeerror: this.backup not function.

so have missed something? javascript client side, why can't execute function?

ps: when executing function notify, when have internet works.

function connection() {   this.backup = function() {     var data = [["backup_scenario"], ["123"]];     var csv = this.createcsv(data);     this.downloadcsv(csv);   }    this.notify = function() {     alert("you have no internet connection anymore");     this.backup();   }    this.createcsv = function(data) {     var linearray = [];     data.foreach(function (infoarray, index) {         var line = infoarray.join(",");         linearray.push(index == 0 ? "data:text/csv;charset=utf-8," + line : line);     });     var csvcontent = linearray.join("\n");     return csvcontent;   }    this.downloadcsv = function(csv) {     var encodeduri = encodeuri(csv);     var link = document.createelement("a");     link.setattribute("href", encodeduri);     link.setattribute("download", "backup.csv");     document.body.appendchild(link); // required ff     link.click();   } } 

sorry, mistake put code directly callback ajax request that:

connection = new connection(); $.ajax({   url: url,   error: connection.notify }); 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -