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

在火狐浏览器中$.ajax中Data值 无法获取
本帖最后由 showbo 于 2013-03-06 19:37:39 编辑
function initData(){
var time = new Date().getTime();
var url2 = "http://hq2gjqh.eastmoney.com/EM_Futures2010NumericApplication/Index.aspx";
$.get(url2,{jsName:"fxrc",Type:"S",SortType:"A",pageSize:"20",page:"1",style:"28CrossRate",_g:time},
function(data){
alert(data);
},"text");

}
$(document).ready(function(){
initData();
});


上面代码中alert(data)在火狐浏览器中取出是空字符串,在IE里面是好的,各位帮忙看看!
Jquery?ajax

------解决方案--------------------
本帖最后由 showbo 于 2013-03-06 19:52:10 编辑
跨域了,无法获取跨域内容的,IE本地测试可以,发布了也不行

需要自己做代理获取跨域的数据

你的这个可以用$.getScript[参数要自己组合起来],而不是$.get


<script src="http://www.coding123.net/js/jquery.js"></script>
<script>

function initData(){
    var time = new Date().getTime();       

    var url2 = "http://hq2gjqh.eastmoney.com/EM_Futures2010NumericApplication/Index.aspx?"+$.param({jsName:"fxrc",Type:"S",SortType:"A",pageSize:"20",page:"1",style:"28CrossRate",_g:time})    ;
    $.getScript(url2,function(){
            alert(fxrc.rank);
        },"text");
     
}
$(document).ready(function(){
    initData();
});
</script>