PDA

View Full Version : AjaxProxy with jsonData as a parameter option with POST method



senchaDevLearner
30 May 2012, 7:01 AM
Hi,


I need to fetch Json data from Rest webservice with method "POST" and pass extra parameters for displaying List value in sencha touch 2.
For this task I am using Store with Ajax Post method and sending extra paramter with jsondata.
I implemented store as like below.


Getting error :
POST http://ipaddress/smapleUrl?_dc=1338380518641 415 (Unsupported Media Type)


Ext
.define(
'prj.store.StoreName',
{
extend : 'Ext.data.Store',
requires : 'prj.model.ModelName',


config : {
model : 'prj.model.ModelName',
storeId : 'StoreNameId',
reader : 'json',
autoLoad : false,
proxy : {
actionMethods : {
read : 'POST'
},
type : 'ajax',
url : 'http://ipaddress/smapleUrl',


extraParams : {
"count" : "30",
"Objects" : "5",
"itemname" : "sample",


},


reader : {
type : 'json',
rootProperty : 'sample'
}
},

});
please help me.

Thanks,

scottmartin
30 May 2012, 5:29 PM
Is your sever not expecting JSON as a valid parameter?

I do not see your call for jsonDate: Ext.encode(mydata)
Are you getting this error from the extraParams and your server does not like it?

Scott.

senchaDevLearner
5 Jun 2012, 3:30 AM
Thanks for your reply,

My problem has been solved by just adding below code, its encoded the request parameter.
writer: {
type : 'json',
encodeRequest: true

}

Thanks,