store学习

本文详细解析了在浏览器环境下遇到的跨域访问错误,并提供了具体的解决步骤,帮助开发者顺利解决资源加载问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

store学习

<script type="text/javascript">
        BUI.use(['bui/grid','bui/data'],function(Grid,Data){
            var Store = Data.Store,
           columns = [
            {title : '表头1',dataIndex :'a', width:100},
            {id: '123',title : '表头2',dataIndex :'b', width:100},
            {title : '表头3',dataIndex : 'c',width:200}
          ];          
        var store = new Store({
            url : '2a.json',
            autoLoad:true
          }),
          grid = new Grid.Grid({
            render:'#grid',
            columns : columns,
            store : store
          });
        grid.render();
      });
    </script>

2a.json数据

{
	"result": true,
	"rows": [{"a":"123"},{"a":"cdd","b":"edd"},{"a":"1333","c":"eee","d":2}],
        "results" : 20
}


在Google浏览器下始终报错

Failed to load resource file:///E:/assets/code/demo.css
Failed to load resource: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. file:///E:/zpj/bui/2a.json?start=0&pageIndex=0&_=1409586123853
XMLHttpRequest cannot load file:///E:/zpj/bui/2a.json?start=0&pageIndex=0&_=1409586123853. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. 2.9grid.html:1
event.returnValue is deprecated. Please use the standard event.preventDefault() instead.

说是浏览器不允许跨域访问具体参见:

http://my.oschina.net/LinBandit/blog/33160

感谢作者的分析。问题完解



转载于:https://my.oschina.net/u/260244/blog/308917

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值