Frederick Cheung wrote:
{"_dc"=>"1217663839339"}
I can get nothing at the serverside.
Now I write the code like below:
var material={code:"000",name:"test"};
params={"material":Object.toJSON(material)}
What are you then doing with the params (on the client side), ie how
are you submitting your request?
Fred
Hi,Fred.Thanks for your reply.
I used the extjs on the client side,it's a javascript framework.
Here is a sample form:
var form=new Ext.FormPanel({
labelWidth: 100,
title:"material",
frame:true,
border:false,
width: 820,
items:[
{fieldLabel: 'code',id:"curcode",name:"material[code]"},
{fieldLabel: 'name',id:"curname",name:'material[name]'}
],
buttons: [
{text:'save',handler:function(){
form.getForm().submit({
method:'POST',
waitTitle:'Connecting',
waitMsg:'Sending data...',
url:'/material/create',
success:function(){Ext.Msg.alert("sucess","sucess");},
failure:function(form, action){
if(action.failureType == 'server'){
obj =
Ext.util.JSON.decodeaction.response.responseText);
Ext.Msg.alert('failure', obj.errors);
}else{
Ext.Msg.alert('Warning!', 'Authentication server is unreachable
: ' + action.response.responseText + "abcd");}
itemform.getForm().reset();
} });
}}
]
})
if I submit it,the params is what I want:
{"material"=>{"code"=>"000","name"=>"test"}}
Now I write a new application.
var queryform=new Ext.FormPanel({
labelWidth: 100,
title:"material",
frame:true,
border:false,
width: 820,
items:[
{fieldLabel: 'code',id:"curcode",name:"material[code]"},
{fieldLabel: 'name',id:"curname",name:'material[name]'}
]
})
var form=new Ext.FormPanel({
labelWidth: 100,
title:"material",
frame:true,
border:false,
width: 820,
items:[{layout:'form',xtype:'panel',autoHeight:true}],
buttons: [
{text:'save',handler:function(){
var material={
code:Ext.getCmp("code")?Ext.getCmp("code").getValue():"",
name:Ext.getCmp("name")?Ext.getCmp("name").getValue():""
};
var mbsstore = new Ext.data.Store(
{
proxy: new Ext.data.HttpProxy({url: '/material/queryresualt/'}),
baseParams:{"material":Object.toJSON(material)},
reader: new Ext.data.JsonReader({root:'items'},[ 'id',
'name_native']),
remoteSort: true
});
mbsstore.load();
}}]})
now the params is: {"material"=>"{\"code\":\"000\",\"name\":\"test\"}"}
if I rewrite the code like this: baseParams:{"material":material)},the
params is: {"_dc"=>"1217663839339"}
My question is,I want send a javascript object(like the material) back
to the serverside,how can I build the params like
{"material"=>{"code"=>"000","name"=>"test"}}