Ajax 使用json和jsonP的区别
我有一个简单的控制器来更新我数据库中的卡车列表。在空间上,它一直在使用jsonP(因为我的服务器在另一个域中),并且工作得很好,但是后来我在同一个域中加入了php脚本(在db中管理crud),我改为使用ajax代理。问题是我注意到虽然ajax代理发送POST请求。。。我什么都没得到。。。(jsonp永远不会出现这种情况,因为我认为它发送了GET请求)。那么,有什么我忘记了或必须做的吗 让我在升级前后显示我的店铺: 之前:Ajax 使用json和jsonP的区别,ajax,extjs,jsonp,store,Ajax,Extjs,Jsonp,Store,我有一个简单的控制器来更新我数据库中的卡车列表。在空间上,它一直在使用jsonP(因为我的服务器在另一个域中),并且工作得很好,但是后来我在同一个域中加入了php脚本(在db中管理crud),我改为使用ajax代理。问题是我注意到虽然ajax代理发送POST请求。。。我什么都没得到。。。(jsonp永远不会出现这种情况,因为我认为它发送了GET请求)。那么,有什么我忘记了或必须做的吗 让我在升级前后显示我的店铺: 之前: Ext.define('myapp.store.ListaCamiones
Ext.define('myapp.store.ListaCamiones', {
extend: 'Ext.data.Store',
requires: [
'myapp.model.Camion'
],
constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
autoLoad: true,
autoSync: true,
model: 'myapp.model.Camion',
storeId: 'ListaCamiones',
proxy: {
type: 'jsonp',
api: {
read: 'http://myapp.localhost/camion/listar',
write: 'http://myapp.localhostt/camion/guardar/',
update: 'http://myapp.localhost/camion/guardar/',
destroy: 'http://myapp.localhost/camion/eliminar/'
},
url: 'http://myapp.localhost/camion/listar',
reader: {
type: 'json',
root: 'listacamion'
},
writer: {
type: 'json',
root: 'listacamion'
}
}
}, cfg)]);
}
});
之后:
Ext.define('myapp.store.ListaCamiones', {
extend: 'Ext.data.Store',
requires: [
'myapp.model.Camion'
],
constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
autoLoad: true,
autoSync: true,
model: 'myapp.model.Camion',
storeId: 'ListaCamiones',
proxy: {
type: 'ajax',
url: '/camion/listar',
api: {
read: '/camion/listar',
write: '/camion/guardar/',
update: '/camion/guardar/',
destroy: '/camion/eliminar/'
},
reader: {
type: 'json',
root: 'listacamion'
},
writer: {
type: 'json',
root: 'listacamion'
}
}
}, cfg)]);
}
});
这是我从chrome调试中得到的:
Connection:Keep-Alive
Content-Length:0
Content-Type:application/x-json
Date:Mon, 01 Jul 2013 15:40:38 GMT
Keep-Alive:timeout=5, max=100
Server:Apache/2.2.22 (Ubuntu)
X-Powered-By:PHP/5.4.9-4ubuntu2
我希望你能帮助我了解正在发生的事情。提前感谢您尝试将您的代理类型更改为“rest”您在服务器端的日志中得到了什么?ajax请求是否达到了预期的终点?192.168.100.150---[01/Jul/2013:12:10:04-0500]“POST/index/login HTTP/1.1”200 412 192.168.100.150---[01/Jul/2013:12:10:31-0500]“POST/camion/eliminar/?\u dc=1372698624678 HTTP/1.1”200 231这是我得到的。。。会发生什么@阿莫尔???