我在主腳本這個...JSONP我做對了嗎?
(function(d){
var shortURLjs, id = 'shortUrl';
if (d.getElementById(id)) {return;}
shortURLjs = d.createElement('script');
shortURLjs.id = id;
shortURLjs.async = true;
shortURLjs.src = "http://site.com/test.js";
d.getElementsByTagName('body')[0].appendChild(shortURLjs);
}(document));
而在test.js我有...
shortURL = { "firstName": "John", "lastName" : "Smith"};
但是,當我試圖從包括在腳本中訪問SHORTURL test.js文件添加後,它沒有定義。
我有點困惑。
Your title is so reddit':P' –
@ŠimeVidas:neh,reddit會使用「釘牢它?」 :) – hugomg