Sencha touch 将值从存储区传递到PHP
我试图将一个值传递给PHP服务器端。我的店铺代码如下Sencha touch 将值从存储区传递到PHP,sencha-touch,sencha-touch-2,sencha-architect,Sencha Touch,Sencha Touch 2,Sencha Architect,我试图将一个值传递给PHP服务器端。我的店铺代码如下 Ext.define('MyApp.store.MyArrayStore', { extend: 'Ext.data.Store', requires: [ 'MyApp.model.MyMOD' ], config: { autoLoad: true, model: 'MyApp.model.MyMOD', storeId: 'MyArray
Ext.define('MyApp.store.MyArrayStore', {
extend: 'Ext.data.Store',
requires: [
'MyApp.model.MyMOD'
],
config: {
autoLoad: true,
model: 'MyApp.model.MyMOD',
storeId: 'MyArrayStore',
proxy: {
type: 'ajax',
actionMethods: 'POST',
url: 'http://localhost/mm/app/php/res.php',
reader: {
type: 'json'
}
},
listeners: [
{
fn: 'onArraystoreBeforeLoad',
event: 'beforeload'
}
]
},
onArraystoreBeforeLoad: function(store, operation, eOpts) {
this.proxy.extraParams.VALUES1 = "pass some name here";
}
});
PHP代码
<?php
error_reporting(E_ERROR | E_PARSE);
require_once 'conn.php'; // contains the connection
$v = $_POST['VALUES1'];
echo json_encode($v);
?>
请尝试
this.getProxy()
,而不是this.proxy
我发现控制台对于这类事情非常有用。在我自己的应用程序中运行Ext.getStore('MyStore').proxy
获取未定义的代理,而Ext.getStore('MyStore').getProxy()
获取我的代理
使用控制台,对我来说,它是仅次于API的最有价值的开发工具
祝你好运,Brad不要使用
这个.proxy
试试这个.getProxy()
我发现控制台对于这类事情非常有用。在我自己的应用程序中运行Ext.getStore('MyStore').proxy
获取未定义的代理,而Ext.getStore('MyStore').getProxy()
获取我的代理
使用控制台,对我来说,它是仅次于API的最有价值的开发工具
祝你好运,Brad你需要改变设置外部参数的方式。。在这种情况下,我将使用
store.getProxy().setExtraParam('VALUES1','pass some name here');
如果需要发送多个参数,请使用setExtraParams
var param = { VALUES1: 'param1', VALUES2 : 'param2'};
store.getProxy().setExtraParams(param);
So完整存储代码
Ext.define('MyApp.store.MyArrayStore', {
extend: 'Ext.data.Store',
requires: [
'MyApp.model.MyMOD'
],
config: {
autoLoad: true,
model: 'MyApp.model.MyMOD',
storeId: 'MyArrayStore',
proxy: {
type: 'ajax',
actionMethods: 'POST',
url: 'http://localhost/mm/app/php/res.php',
reader: {
type: 'json'
}
},
listeners: [
{
fn: 'onArraystoreBeforeLoad',
event: 'beforeload'
}
]
},
onArraystoreBeforeLoad: function(store, operation, eOpts) {
store.getProxy().setExtraParam('VALUES1 ','pass some name here');
}
});
您需要更改设置外部参数的方式。。在这种情况下,我将使用
store.getProxy().setExtraParam('VALUES1','pass some name here');
如果需要发送多个参数,请使用setExtraParams
var param = { VALUES1: 'param1', VALUES2 : 'param2'};
store.getProxy().setExtraParams(param);
So完整存储代码
Ext.define('MyApp.store.MyArrayStore', {
extend: 'Ext.data.Store',
requires: [
'MyApp.model.MyMOD'
],
config: {
autoLoad: true,
model: 'MyApp.model.MyMOD',
storeId: 'MyArrayStore',
proxy: {
type: 'ajax',
actionMethods: 'POST',
url: 'http://localhost/mm/app/php/res.php',
reader: {
type: 'json'
}
},
listeners: [
{
fn: 'onArraystoreBeforeLoad',
event: 'beforeload'
}
]
},
onArraystoreBeforeLoad: function(store, operation, eOpts) {
store.getProxy().setExtraParam('VALUES1 ','pass some name here');
}
});
您是否检查了控制台中是否有错误。。因为我觉得应该有个错误是的。错误为
未捕获类型错误:无法读取未定义的属性“extraParams”
是否检查了console中是否存在错误。。因为我觉得应该有个错误是的。错误为uncaughttypeerror:无法读取未定义的属性“extraParams”
我仍然收到错误:MyJsonReader1无法读取数据。在浏览器中打开:http://localhost......
。原因是PHP返回的是null。所以我猜VALUES1的值不是在PHP端拾取的。有什么线索吗?应该是actionMethods
还是actionMethod
?我仍然得到一个错误:MyJsonReader1无法读取数据。在浏览器中打开:http://localhost......
。原因是PHP返回的是null。所以我猜VALUES1的值不是在PHP端拾取的。有什么线索吗?应该是actionMethods
还是actionMethod
?是的,我也尝试过你的方法,但我仍然得到一个错误:MyJsonReader1无法读取数据。在浏览器中打开:http://localhost......
。我认为原因是PHP返回null(当我回显响应时,它返回null)。所以我猜VALUES1
的值不是在PHP端选取的。有什么线索可以解决这个问题吗?使用开发人员控制台中的“网络”选项卡来查看哪些参数实际通过了。它似乎没有被发布(通过)。您是指存储
?。如果是这样的话,我已经在上面添加了它。当加载页面时,它应该向php发送一个请求,并在视图上显示记录。调用类似于getProxy().setUrl(getProxy().getUrl()+'?EXTRA1=“此处的某个名称”)
。再次为语法感到抱歉,但这种逻辑应该可以工作。如果您不需要动态添加'some name here'参数,您也可以直接将其添加到代理中的url。是的,我也尝试了您的方法,但仍然遇到错误:MyJsonReader1无法读取数据。在浏览器中打开:http://localhost......
。我认为原因是PHP返回null(当我回显响应时,它返回null)。所以我猜VALUES1
的值不是在PHP端选取的。有什么线索可以解决这个问题吗?使用开发人员控制台中的“网络”选项卡来查看哪些参数实际通过了。它似乎没有被发布(通过)。您是指存储
?。如果是这样的话,我已经在上面添加了它。当加载页面时,它应该向php发送一个请求,并在视图上显示记录。调用类似于getProxy().setUrl(getProxy().getUrl()+'?EXTRA1=“此处的某个名称”)
。再次为语法感到抱歉,但这种逻辑应该可以工作。如果您不需要动态添加'somename here'参数,也可以直接将其添加到代理中的url。