Quantcast
Channel: 神戸ホームページ制作会社ユニファースの代表ブログ
Viewing all articles
Browse latest Browse all 221

$.getScript でエラーが発生する場合の対処

$
0
0
$.getScript("https://xx.jp/f_common.js");

を実行した時、

Uncaught TypeError: Cannot read property ‘menu’ of undefined

のようなエラーが発生しました。

調べてみると、「$.getScriptは非同期操作のみをサポートしている」とのことです。

以下のコードに変更したら、無事にエラーがでなくなりました。

$.ajax({ 
url: 'https://xx.jp/f_common.js', 
async: false, 
dataType: "script", 
});

 


Viewing all articles
Browse latest Browse all 221

Latest Images

Trending Articles