AJAX将javascript文件作为文本文件读取(防止代码重复)

时间:2012-09-27 07:12:01

标签: javascript jquery ajax

如何将javascript文件作为文本文件读取并防止代码多次运行

index.js

  version = "1.001";
  alert("JS run");
  ... other code ...

我有html使用index.js
我尝试使用

读取index.js
jQuery.get("js/index.js",function(data){ 
    var currentVersion = data.split("\n")[0].split('"')[1];
}

我可以按照自己的意愿阅读文字,但警报(“JS run”)和其他代码也在我使用此代码后运行。

0 个答案:

没有答案