butteryrose 发表于 2013-1-29 08:50:32

ie6 json 跨域请求问题

天在做js 跨域请求的时候发现一个问题
在ie6 下不正常,ie7/8 ff 都正常
研究了1天都没找到原因,向各位大侠求助
 
js代码如下
function load_quote_data(url,callback) {      var ran_n=Math.round(Math.random()*10000001);      var newscript = document.createElement("script");newscript.onload = newscript.onreadystatechange = function(){       if(!_done &&(!this.readyState || this.readyState === "loaded" || this.readyState === "complete")){         _done = true;         callback();               setTimeout(function(){try{ newscript.parentNode.removeChild(newscript); }catch(e){} },500);         newscript.onload = newscript.onreadystatechange = null;       }};      newscript.type = "text/javascript";      // 加随机数避免缓存      newscript.src = url+"&ran="+ran_n;      var _done = false;      newscript.id = "load_data_id";      document.getElementsByTagName("head").appendChild(newscript);      setTimeout(function(){try{ newscript.parentNode.removeChild(newscript); }catch(e){} },800);} 
通过上述调用之后,能正常返回json数据 格式为 market = {name:'scott'};
但是 在 调用callback()
的是时候,获取到的market.name 为'undefined';
 
不知道为什么, 且只有在ie6下出现这种问题,哪位大虾帮帮忙?
 
 
 
问题解决了,是编码问题,后台和前台编码不一致造成的!
 
 
 
页: [1]
查看完整版本: ie6 json 跨域请求问题