PDA

View Full Version : Ext.Ajax.request params problem



9 Feb 2010, 7:02 PM
params = ''
for(var i=0;i<IfieldName.length;i++){
paramsValue = Ext.getDom(IfieldName[i]).value
if(paramsValue==undefined){paramsValue=''}
params = params+IfieldName[i]+':\''+paramsValue+'\','
}
params = params+'formID:\''+formID+'\''
params = '[{'+params+'}]'
//alert(params):"[{workFlowName:'??',workFlowDiv:'test',workFlowOrder:'1',formID:'5'}]"
params = eval(params)
//alert(params):object
Ext.Ajax.request({
url:"/DataOperate/exeFormInsert.asp",
params:params,
success:function(response){
eval(response.responseText)
loadList(page)
win.destroy();
}
})



please tell me what's wrong whih this code~

DataOperate/exeFormInsert.asp is fine
when I user Jquery it's all ok~




params = ''
for(var i=0;i<IfieldName.length;i++){
paramsValue = Ext.getDom(IfieldName[i]).value
if(paramsValue==undefined){paramsValue=''}
params = params+IfieldName[i]+'='+paramsValue+'&'
}
params = params+'formID='+formID
$.ajax({
type:'post',
url:"/DataOperate/exeFormInsert.asp (http://www.extjs.com/forum/"/DataOperate/exeFormInsert.asp)",
data:params,
dataType:'script',
success:function(){
loadList(page)
win.destroy();
}
})

Mike Robinson
10 Feb 2010, 8:53 AM
:-? You're giving us a piece of code, "to debug it for you," without so much as a hint of what is wrong with it?

For one thing: parameters (and base-parameters or extra-parameters) should be expressed in your code as JavaScript objects. Ext is responsible for whatever encoding may be necessary.

You do not have to, and should not, laboriously construct JSON-strings yourself. (When you actually have to do that, you have "Ext.encode()" and "Ext.decode().")

10 Feb 2010, 9:41 AM
i agree with mike. If you don't speak english well, then post in your native language.