动态Script标签 解决跨域问题
动态Script 解决跨域问题
1.动态创建script
createScript : function(src)
{
var varScript = document.createElement("script");
if (src != "") {
varScript.src = src;
}
varScript.language = "javascript";
varScript.type = "text/javascript";
document.body.appendChild(varScript);
}
src:url(跨域地址)?参数列表n=值n&callback=callbackMethod
2.回调方法callbackMethod
function callbackMethod(data){
}
1.动态创建script
createScript : function(src)
{
var varScript = document.createElement("script");
if (src != "") {
varScript.src = src;
}
varScript.language = "javascript";
varScript.type = "text/javascript";
document.body.appendChild(varScript);
}
src:url(跨域地址)?参数列表n=值n&callback=callbackMethod
2.回调方法callbackMethod
function callbackMethod(data){
}