首页新闻找找看学习计划

js跨域在谷歌火狐浏览器不支持

0
[待解决问题]

     前端:   $.getJSON("http://stock.emoney.cn/DefaultTest.aspx", function (data) {
            alert(data.toString());
            $("#div001").html(data.toString());
             //alert(result);
            var obj = $("#tabLia  .current")[0]
            var index = $("#tabLia li").index(obj);
            $("#tabLia_c" + index).show();
    });

 

后台是返回字符串:

 

  protected string showIdx_idx()
    {
        StringBuilder sb = new StringBuilder();

        string[] ArrIdx = new string[] { "000001", "399001", "000300", "399101", "399006", "global" };

        string str = Pub.LoadData(jsonUrl + "hangqing/hyzyzslb.ashx");
        List<ZshqEnty> list = JsonConvert.DeserializeObject<List<ZshqEnty>>(str);
        List<ZshqEnty> list2 = new List<ZshqEnty>();
        for (int i = 0; i < ArrIdx.Length; i++)
        {
            switch (i)
            {
                case 0:
                case 1:
                case 2:
                case 3:
                case 4:
                    list2 = list.Where(x => x.code == ArrIdx[i]).ToList();
                    if (list2.Count > 0)
                    {
                        sb.AppendFormat("<div class=\"chart\" id=\"tabLia_c{0}\" style=\"display:block;\">", i);
                        sb.AppendFormat("<div class=\"data\">");
                        string cls = "red";
                        if (OTO.ToDecimal(list2[0].D, 0) < 0)
                            cls = "green";
                        sb.AppendFormat("<div class=\"{0}\">", cls);
                        sb.AppendFormat("<a href=\"{2}Dp{1}.shtml\" class=\"b\">{0}</a>&nbsp;&nbsp;&nbsp;&nbsp;", list2[0].scmc, list2[0].code, quoteUrl);
                        sb.AppendFormat("<span class=\"font14\">");
                        if (OTO.ToDecimal(list2[0].P, 0) == 0)
                        {
                            sb.AppendFormat("-&nbsp;&nbsp;&nbsp;&nbsp;");
                            sb.AppendFormat("-&nbsp;&nbsp;&nbsp;&nbsp;");
                            sb.AppendFormat("-</span>");
                        }
                        else
                        {
                            sb.AppendFormat("{0}&nbsp;&nbsp;&nbsp;&nbsp;", OTO.ToDecimal(list2[0].P, 0));
                            sb.AppendFormat("{0}&nbsp;&nbsp;&nbsp;&nbsp;", OTO.ToDecimal(list2[0].D, 0));
                            sb.AppendFormat("{0}</span>", OTO.ToDecimal(list2[0].F, 1, 2, "%", "-"));
                        }
                        sb.AppendFormat("</div>");

                        sb.AppendFormat("</div>");
                        sb.AppendFormat("<a href=\"{1}DP{0}.shtml\" target=\"_blank\"><img src=\"http://www.ymcps.com/images/zhishunew/{0}.jpg\" alt=\"\" width=\"230\" height=\"120\" /></a>", ArrIdx[i], quoteUrl);
                        sb.AppendFormat("</div>");
                    }
                    break;
                case 5:
                    sb.AppendFormat("<div class=\"chart\" style=\"display:none;\" id=\"tabLia_c{0}\">", i);
                    sb.AppendFormat("<div class=\"global\">");
                    string con = Pub.LoadData(jsonUrl + "stock/zhishu.ashx?code=HSI,dji,nasdaq,GC,CL");
                    List<StockZhiShuEnty> list3 = Newtonsoft.Json.JsonConvert.DeserializeObject<List<StockZhiShuEnty>>(con);

                    if (list3 != null && list3.Count > 0)
                    {
                        sb.AppendFormat("<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">");
                        foreach (var m in list3)
                        {
                            sb.AppendFormat("<tr>");
                            sb.AppendFormat("<td style=\"color:#0D519C;\">{0}</td>", m.CnCode);
                            sb.AppendFormat("<td class=\"{1}\">{0}</td>", OTO.ToDecLine(m.zs, 2, "-", ""), OTO.ToDecimal(m.zd, 0) >= 0 ? "red" : "green");
                            sb.AppendFormat("<td class=\"{1}\">{0}</td>", OTO.ToDecLine(m.zd, 2, "-", ""), OTO.ToDecimal(m.zd, 0) >= 0 ? "red" : "green");
                            sb.AppendFormat("<td class=\"{1}\">{0}</td>", OTO.ToDecLine(m.zdf, 2, "-", ""), OTO.ToDecimal(m.zd, 0) >= 0 ? "red" : "green");
                            sb.AppendFormat("</tr>");
                        }
                        sb.AppendFormat("</table>");
                    }
                    sb.AppendFormat("</div>");
                    sb.AppendFormat("</div>");
                    break;
            }
        }
        return sb.ToString();
    }

snjsunyan的主页 snjsunyan | 初学一级 | 园豆:55
提问于:2012-05-02 15:37
< >
分享
所有回答(4)
0
xu_happy_you | 园豆:222 (菜鸟二级) | 2012-05-02 15:47
1

使用jsonp增加?callback=

````` | 园豆:14268 (专家六级) | 2012-05-02 20:49
0
dudu | 园豆:41010 (高人七级) | 2012-05-03 09:57
0
gitbuild | 园豆:587 (小虾三级) | 2012-05-04 11:51
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册