Hi all,
I'm new to Sencha Touch and want to build a simple form panel which will be send to a REST service which is implement with Java jersey. The webservice is working properly (tested with Soap UI) and also the sencha app is working fine until I'll press the submit button of the form and if I'm using the submit() function. If I use Ajax in the button handler, the webservice will be called properly, otherwise I get following exception at the webservice:
Code:
Caused by: java.lang.Error: Error: could not match input at
com.sun.jersey.json.impl.reader.JsonLexer.zzScanError(JsonLexer.java:491)
at com.sun.jersey.json.impl.reader.JsonLexer.yylex(JsonLexer.java:736)
Sencha code:
Code:
{
text: 'Save',
ui: 'confirm',
handler: function() {
console.log('storing');
var form = Ext.getCmp('checkoutform');
console.log(Ext.JSON.encode(form.getValues()));
form.submit({
url: 'http://localhost:8080/example/service/',
method:'POST',
headers: {
'Content-Type': 'application/json'
},
params: Ext.JSON.encode(form.getValues()),
success:function(form, result){
console.log("succ");
},
failure:function(form, result){
console.log("fail");
}
});
}
}
If i use the following code the call of the webservice is working fine:
Code:
{
text: 'Save',
ui: 'confirm',
handler: function() {
console.log('storing');
var form = Ext.getCmp('checkoutform');
console.log(Ext.JSON.encode(form.getValues()));
Ext.Ajax.request({
url: 'http://localhost:8080/example/service/',
method:'POST',
headers: {
'Content-Type': 'application/json'
},
params: Ext.JSON.encode(form.getValues()),
})
}
}
Does anyone have an idea why the form.submit function is sending anything but not properly json data?
btw. form.getValues() returns json data:
Code:
{"name":"","address":""}