PDA

View Full Version : from submit problem



iamghd2001
2 Mar 2010, 6:01 AM
code:
js:
form.form.submit({
url:'/action' (http://www.extjs.com/forum/'/action'),
method:'post',
success:function(form,action){
//code1
},failure:function(form,action){
}
})
servlet:
String json="{name:'ab c'}"; //three space in 'ab c'
response.getWriter.print(json);
at code1:the value of action.result.name is 'ab c' (one space in 'ab c')
why only one space left in the value of action.result.name

Troy Wolf
2 Mar 2010, 6:53 AM
code:
js:
form.form.submit({
url:'/action' (http://www.extjs.com/forum/'/action'),
method:'post',
success:function(form,action){
//code1
},failure:function(form,action){
}
})
servlet:
String json="{name:'ab c'}"; //three space in 'ab c'
response.getWriter.print(json);
at code1:the value of action.result.name is 'ab c' (one space in 'ab c')
why only one space left in the value of action.result.name

Also note that when reading your post, you only see a single space in 'ab c'. Remember that HTML will suppress continuous spaces into a single space. This leads me to wonder exactly HOW and WHY you think the value at code1 only has a single space. If you are displaying the value to the browser window or in an Ext.MessageBox, it will be displayed as HTML, and thus your 3 spaces appear as 1.

If this is not your issue, reply back and we'll see what we can do to help. ~o)

iamghd2001
2 Mar 2010, 6:20 PM
Thanks for your reply.
I'm looking up the value by using alert.
But I'm puzzling about this problem.
When I change the way of submit(use Ext.Ajax.request)

example:
js:
Ext.ajax.request({
url:'/action' (http://www.extjs.com/forum/'/action'),
method:'post',
success:function(response,request){
//code1
},failure:function(response,request){
}
})

servlet:(no change)
String json="{name:'ab c'}"; //three space in 'ab c'
response.getWriter.print(json);

at code1:the value of Ext.util.JSON.decode(response.responseText).name is 'ab c' (now three space in 'ab c')
why ?