Javascript 未调用Sencha存储代理
我想动态加载存储数据,不想为此使用模型。若我提供的数据列表被填充,但若我使用商店的代理,它不会被调用,url也不会被点击。请帮忙Javascript 未调用Sencha存储代理,javascript,extjs,sencha-touch-2,jsonp,Javascript,Extjs,Sencha Touch 2,Jsonp,我想动态加载存储数据,不想为此使用模型。若我提供的数据列表被填充,但若我使用商店的代理,它不会被调用,url也不会被点击。请帮忙 Ext.define('TrainEnquiry.view.SearchTrainResults', { extend: 'Ext.List', xtype: 'searchedtrainresult', requires: 'Ext.data.proxy.JsonP', config: { itemId: 'searched
Ext.define('TrainEnquiry.view.SearchTrainResults', {
extend: 'Ext.List',
xtype: 'searchedtrainresult',
requires: 'Ext.data.proxy.JsonP',
config: {
itemId: 'searchedtrainresult',
title: 'Train Result:',
itemTpl: '<div class="myContent">'+
'<div><b>{number}</b> </div>' +
'</div>',
store: {
fields: ['number'],
/*data: [
{number: 'Cowper'},
{number: 'Everett'},
{number: 'University'},
{number: 'Forest'}
]*/
proxy: {
url: 'http://abc.amazonaws.com/search.json',
type:'jsonp',
extraParams : {
'q' : '12313'
},
reader: {
type: 'json',
},
success: function() {
debugger;
console.log('success');
},
failure: function() {
debugger;
console.log('failure');
}
}
},
onItemDisclosure: true
}
});
Ext.define('trainquery.view.SearchTrainResults'{
扩展:“Ext.List”,
xtype:“searchedtrainresult”,
需要:“Ext.data.proxy.JsonP”,
配置:{
itemId:“searchedtrainresult”,
标题:“训练结果:”,
itemTpl:''+
“{number}”+
'',
商店:{
字段:['number'],
/*数据:[
{编号:'Cowper'},
{编号:'Everett'},
{编号:'大学'},
{编号:'林'}
]*/
代理:{
网址:'http://abc.amazonaws.com/search.json',
类型:'jsonp',
外部参数:{
‘q’:‘12313’
},
读者:{
键入:“json”,
},
成功:函数(){
调试器;
console.log('success');
},
失败:函数(){
调试器;
console.log('failure');
}
}
},
这是真的吗
}
});
尝试将代理存储的类型更改为Ajax(类型:“Ajax”)。就这样
Ext.create('Ext.data.Store', {
model: 'User',
proxy: {
type: 'ajax',
url: '/test.json',
reader: {
type: 'json',
}
},
autoLoad: true
});
Ext.create('Ext.data.Store', {
storeId:'UserStore',
autoLoad: true,
model: 'UserModel',
proxy: {
type: 'jsonp', // Because it's a cross-domain
url : 'https://api.twitter.com/1/lists/members.json?owner_screen_name=Sencha&slug=sencha-team&skip_status=true',
reader: {
type: 'json',
root: 'users' // The returned JSON will have array
// of users under a "users" property
},
// Removing pageParam and startParam
pageParam: undefined,
startParam: undefined
}
});
我认为您的“字段”配置选项需要是一个合适的选项,所以这可能会起作用:
Ext.define('TrainEnquiry.view.SearchTrainResults', {
...
config: {
...
store: {
fields: [ { name: 'number', type: 'string'} ],
proxy: {
...
}
},
...
}
});
(引用自)您可以尝试从代理中删除pageParam和startParam。就这样
Ext.create('Ext.data.Store', {
model: 'User',
proxy: {
type: 'ajax',
url: '/test.json',
reader: {
type: 'json',
}
},
autoLoad: true
});
Ext.create('Ext.data.Store', {
storeId:'UserStore',
autoLoad: true,
model: 'UserModel',
proxy: {
type: 'jsonp', // Because it's a cross-domain
url : 'https://api.twitter.com/1/lists/members.json?owner_screen_name=Sencha&slug=sencha-team&skip_status=true',
reader: {
type: 'json',
root: 'users' // The returned JSON will have array
// of users under a "users" property
},
// Removing pageParam and startParam
pageParam: undefined,
startParam: undefined
}
});
这是一个跨领域的例子。因此,我将不得不使用jsonp而不是ajax。它仍然没有被调用。您是如何获得工作的?