有时不得加载jq, 记录一下简单常用的函数
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
var getJSON = (function(){ var loadJsFile = function(file){ var head = ghead(); var e = document.createElement("script"); e.type="text/javascript"; e.src=file; head.appendChild(e); }; var ghead = function(){ var head, o = document; ((head = o.getElementsByTagName('head')[0]) || (head = o.body.parentNode.appendChild(o.createElement("head")))); return head; } return function(url, callback) { var tmpCallback = 'JCallback' + Math.ceil(Math.random() * 1000000); window[tmpCallback] = function(data){ callback(data); }; url = url + "&callback=" + tmpCallback ; loadJsFile(url); } })(); |
没有同相同url地址判断