javascript - How to catch Uncaught typeerror: cannot read property 'datatable' of undefined. error -


when turn off google api "uncaught typeerror: cannot read property 'datatable' of undefined" message.

i catch undefined error , have window popping saying "google has been disabled" i'm not sure typeof object undefined. i'm checking "datatable" object i'm pretty sure wrong window pops regardless now.

here code.

var data = new google.visualization.datatable(); if(typeof datatable == "undefined"){ window.alert("sometext"); } else { data.addcolumn('string', 'name'); data.addcolumn('string', 'manager'); data.addcolumn('string', 'tooltip'); data.addcolumn('string', 'type'); data.addcolumn('string', 'code'); data.addcolumn('string', 'aggregation'); data.addcolumn('string', 'stage');  data.addrows([ <xsl:apply-templates select="/*" mode="render"/> ['1','2','3','4','5','6','7'] ]);  data.removerow(data.getnumberofrows() - 1);  drawdebugflow(data); } 

instead of:

if(typeof datatable == "undefined"){ 

use:

if(typeof google == "undefined" || typeof google.visualization == "undefined"){ 

error "uncaught typeerror: cannot read property 'datatable' of undefined" not "datatable undefined"


Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -