Ext4 两种访问Restful 方式

来源:互联网 发布:视频编辑软件免费版 编辑:程序博客网 时间:2024/05/22 00:09

1. datastore 方式

Ext.define('User', {
      extend: 'Ext.data.Model',
      fields: ['id', 'name', 'email']
  });


  var s1 = Ext.create('Ext.data.Store', {
       model: 'User',
  autoload:false,
       proxy: {
     type : 'rest',
             url : 'http://127.0.0.1:8080/mypath/rest/resources/my'
       }
  });


2. 

    a. 

      Ext.Ajax.cors=true;
Ext.Ajax.useDefaultXhrHeader=false;

Ext.Ajax.request( {

  url : 'http://127.0.0.1:8080/mypath/rest/resources/my',
method:'get',
success:function(response) {
console.info(response);
}
});

b.

Ext.Ajax.request( {

useDefaultXhrHeader:false,
  cors:true,

  url : 'http://127.0.0.1:8080/mypath/rest/resources/my',
method:'get',
success:function(response) {
console.info(response);
}
});


0 0
原创粉丝点击