原来jsonp这么实现啊

前端之家收集整理的这篇文章主要介绍了原来jsonp这么实现啊前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
function loginRequest(jsonp){
rnd = getRnd();
c_url = "http://reg.163.com/services/httpLoginExchgKey?rnd="+rnd;
c_url += "&jsonp="+jsonp;
fGetJson(c_url);
}

function getRnd(){ 
//var uid = $("idInput").value + "@163.com";
var timestamp = new Date().getTime();
//var rnd = base64encode(utf16to8(uid + "\n" + timestamp));
var rnd = base64encode(utf16to8("\n" + timestamp));
return rnd;
}

function fGetJson(url){
var oHead = document.getElementsByTagName("HEAD")[0] || document.documentElement;
var sForJson = document.createElement("script"); 
oHead.insertBefore( sForJson,oHead.firstChild );
//sForJson.setAttribute("charset","gb2312"); 
sForJson.setAttribute("type","text/javascript");
sForJson.setAttribute("src",url);
}

但是有个疑惑 jsonp 不能异步么? 难不成只能在IE上 jsonp 能实现异步么?

原文链接:https://www.f2er.com/json/289227.html

猜你在找的Json相关文章