michaelreneer
8 Nov 2011, 8:06 AM
First, please forgive me if this is a duplicate bug post. I searched and could not find this issue, but I am new to sencha touch and this forum so I may have missed it.
Ext version tested:
Sencha Touch 2.0.0.pr1
Browser versions tested against:
Safari 5.1.1 (Mac OS X)
DOCTYPE tested against:
<!DOCTYPE html>
Description:
I am trying to use an proxy on a store to populate a list. I need to send the read request as a POST request, set the Content-Type to json, and encode the parameters as json.
Steps to reproduce the problem:
Create Ext.data.Model
Create Ext.data.Store, set ajax proxy and it's actionMethods, header, reader, and url
Create Ext.List and set the store
The result that was expected:
A populated list.
The result that occurs instead:
500 Internal Server Error
Test Case:
Ext.define('app.model.Thing', {
extend: 'Ext.data.Model',
fields: [
{name: 'name', type: 'string'}
]
});
Ext.define('app.store.Things', {
autoLoad: true,
extend: 'Ext.data.Store',
model: 'app.model.Thing',
proxy: {
actionMethods: {
create: 'POST',
read: 'POST',
update: 'POST',
destroy: 'POST'
},
headers: {
'Content-Type': 'application/json; charset=utf-8'
},
reader: {
type: 'json',
root: 'd'
},
type: 'ajax',
url: 'http://...service.asmx/GetThings',
extraParams: {
id: '',
token: '',
filter: ''
},
writer: 'json'
},
});
var list = Ext.create('Ext.List', {
itemTpl: '{name}',
store: 'Things'
});
This code gives me a request of:
Request URL:http://...service.asmx/GetThings
Request Method:POST
Status Code:500 Internal Server Error
Request Headers
Content-Type:application/json; charset=UTF-8
Origin:file://
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/534.51.22 (KHTML, like Gecko) Version/5.1.1 Safari/534.51.22
X-Requested-With:XMLHttpRequest
Request Payload
id=&token=&filter=
Response Headers
Cache-Control:private
Content-Length:91
Content-Type:application/json; charset=utf-8
Date:Tue, 08 Nov 2011 15:12:40 GMT
jsonerror:true
Server:Microsoft-IIS/7.5
X-AspNet-Version:4.0.30319
X-Powered-By:ASP.NET
I can achieve the expected request, however, if I either:
1) On the store: set autoLoad to false and don't set either the extraParams or writer properties. Call the stores load() method with an encoded json object:
this.getThingsStore().load({
params: Ext.JSON.encode({
id: '',
token: '',
filter: ''
})
});
2) Use Ext.Ajax to make the request:
Ext.Ajax.request({
headers: {
'Content-Type': 'application/json; charset=utf-8'
},
method: 'POST',
params: Ext.JSON.encode({
id: '',
token: '',
filter: ''
}),
url: 'http://...service.asmx/GetThings'
});
Either of the above methods yield the following request:
Request URL:http://...service.asmx/GetThings
Request Method:POST
Status Code:200 OK
Request Header
Content-Type:application/json; charset=UTF-8
Origin:file://
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/534.51.22 (KHTML, like Gecko) Version/5.1.1 Safari/534.51.22
X-Requested-With:XMLHttpRequest
Request Payload
{"id":"","token":"","filter":""}
Response Headers
Cache-Control:private, max-age=0
Content-Length:15664
Content-Type:application/json; charset=utf-8
Date:Tue, 08 Nov 2011 15:56:41 GMT
Server:Microsoft-IIS/7.5
X-AspNet-Version:4.0.30319
X-Powered-By:ASP.NET
Please note that the reqeust payload is json.
Ext version tested:
Sencha Touch 2.0.0.pr1
Browser versions tested against:
Safari 5.1.1 (Mac OS X)
DOCTYPE tested against:
<!DOCTYPE html>
Description:
I am trying to use an proxy on a store to populate a list. I need to send the read request as a POST request, set the Content-Type to json, and encode the parameters as json.
Steps to reproduce the problem:
Create Ext.data.Model
Create Ext.data.Store, set ajax proxy and it's actionMethods, header, reader, and url
Create Ext.List and set the store
The result that was expected:
A populated list.
The result that occurs instead:
500 Internal Server Error
Test Case:
Ext.define('app.model.Thing', {
extend: 'Ext.data.Model',
fields: [
{name: 'name', type: 'string'}
]
});
Ext.define('app.store.Things', {
autoLoad: true,
extend: 'Ext.data.Store',
model: 'app.model.Thing',
proxy: {
actionMethods: {
create: 'POST',
read: 'POST',
update: 'POST',
destroy: 'POST'
},
headers: {
'Content-Type': 'application/json; charset=utf-8'
},
reader: {
type: 'json',
root: 'd'
},
type: 'ajax',
url: 'http://...service.asmx/GetThings',
extraParams: {
id: '',
token: '',
filter: ''
},
writer: 'json'
},
});
var list = Ext.create('Ext.List', {
itemTpl: '{name}',
store: 'Things'
});
This code gives me a request of:
Request URL:http://...service.asmx/GetThings
Request Method:POST
Status Code:500 Internal Server Error
Request Headers
Content-Type:application/json; charset=UTF-8
Origin:file://
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/534.51.22 (KHTML, like Gecko) Version/5.1.1 Safari/534.51.22
X-Requested-With:XMLHttpRequest
Request Payload
id=&token=&filter=
Response Headers
Cache-Control:private
Content-Length:91
Content-Type:application/json; charset=utf-8
Date:Tue, 08 Nov 2011 15:12:40 GMT
jsonerror:true
Server:Microsoft-IIS/7.5
X-AspNet-Version:4.0.30319
X-Powered-By:ASP.NET
I can achieve the expected request, however, if I either:
1) On the store: set autoLoad to false and don't set either the extraParams or writer properties. Call the stores load() method with an encoded json object:
this.getThingsStore().load({
params: Ext.JSON.encode({
id: '',
token: '',
filter: ''
})
});
2) Use Ext.Ajax to make the request:
Ext.Ajax.request({
headers: {
'Content-Type': 'application/json; charset=utf-8'
},
method: 'POST',
params: Ext.JSON.encode({
id: '',
token: '',
filter: ''
}),
url: 'http://...service.asmx/GetThings'
});
Either of the above methods yield the following request:
Request URL:http://...service.asmx/GetThings
Request Method:POST
Status Code:200 OK
Request Header
Content-Type:application/json; charset=UTF-8
Origin:file://
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/534.51.22 (KHTML, like Gecko) Version/5.1.1 Safari/534.51.22
X-Requested-With:XMLHttpRequest
Request Payload
{"id":"","token":"","filter":""}
Response Headers
Cache-Control:private, max-age=0
Content-Length:15664
Content-Type:application/json; charset=utf-8
Date:Tue, 08 Nov 2011 15:56:41 GMT
Server:Microsoft-IIS/7.5
X-AspNet-Version:4.0.30319
X-Powered-By:ASP.NET
Please note that the reqeust payload is json.