日期:2014-05-16  浏览次数:20424 次

原来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 能实现异步么?