PDA

View Full Version : Form Submit always going in Failure function (callback)



piyushsuny
1 Jan 2015, 10:48 AM
Hello All,

Kindly help in one issue:-

Form Submit always going in Failure function (callback) even though success is returned in the JSON response, below is my code:-

headerDetailForm.submit({
clientValidation: false, //done above
url : isNewLead ? '/leadmanagementservice/addLead' : '/leadmanagementservice/updateLead',
method: 'POST',
params: {
requestOrganizationId: headerDetailForm.findField('operUnitId').getValue(),
OU: User.ou,
requestOrganizationId : User.ou ,
organizationId :User.swbOu,
responsibilityId : User.swbResponsibilityId,
id : isNewLead ? '' : headerDetailForm.findField('id').getValue()
},
success: function(form, action) {
//this === view
var data, toolbar, field;
mask.hide().destroy();
-------------------------
}

Json Response:-

{"leadmanagementservicedata": {
"responseStatus": {
"returnCode": 0,
"returnMessage": "Lead Updated"
},
"success": true,
"total": 1,
"lead": {
"id": 190,
"leadNumber": 62,
"ownerId": 0,
"company": "Frank's Company NE"
}
}}

Here is the code of the form:-

Ext.define('LWB.view.form.LeadDetail', {
extend: 'Ext.form.Panel',
alias: 'widget.leadheaderform',
requires: ['LWB.model.LeadHeader'],
title: 'Lead Header',
bodyPadding: 0,
autoScroll: true,
bodyCls: 'swb-form-panel',
layout: 'absolute',
reader: new Ext.data.JsonReader({
root: 'leadmanagementservicedata.lead',
successProperty: 'leadmanagementservicedata.success',
model: 'LWB.model.LeadHeader',
}),
------------
------------

Every time after the form submit, the control goes into failure block, even though the json response has success as true and it is a valid json.

Gary Schlosberg
6 Jan 2015, 5:15 AM
Does your code have a file upload in it?
http://www.sencha.com/forum/showthread.php?282364

In your JSON response, does it work if you move "success": true to be outside of the leadmanagementservicedata block?

piyushsuny
18 Jan 2015, 12:16 AM
Thanks Gary for your response.

No my code doesnt have a file upload.

And yes if i move 'success' up from my leadmanagementservice data block it works properly.

But i have to make it work in this way only, because while configuring the Json Reader in my form I am defining the success property as leadmanagementservicedata.success so ideally it should work properly.