PDA

View Full Version : Form Load



deblasio
10 Sep 2008, 8:48 AM
I have a simple FormPanel that I am trying to load from aspx, the code is as follows:



var demoform = new Ext.FormPanel({
defaultType : 'textfield',
layout:'absolute',
url:'admin.aspx',
width:750,
height:350,
bodyStyle:'padding:5px 5px 0',
frame:true,
buttons: [{
text: 'Save',
handler: function()
{
}
},{
text: 'Cancel',
handler: function()
{
}
}],
items: [
{
name: 'idcode',
x: 105,
y: 22,
width: 112,
height: 19,
xtype: 'textfield',
}]
});

if (id_code!="") demoform.load({
url: 'admin.aspx',
method: 'post',
params: { mode: 'get_patient', pass_id_code: id_code},
success: function(form, action)
{
var response = Ext.util.JSON.decode(action.response.responseText);
Ext.MessageBox.alert('Success', 'Success');
},
failure: function(form, action)
{
var response = Ext.util.JSON.decode(action.response.responseText);
Ext.MessageBox.alert('Errors', 'Failed');
}
});
id_code is just some variable with a value. The form is part of a tab panel, however I left that section of the code out. The problem I am having is that every time I call the load function I keep getting a failure even though my response from the .aspx is a valid Json string containing the success : true. According to firebug the response I am getting is :

{success: true, idcode: '1'}

which is exactly what I am expecting, but for some reason I keep getting stuck in the failure. Any ideas why this load is failing. I tried debugging but I am not too familiar with all the aspects of firebug.

devnull
10 Sep 2008, 9:01 AM
Read the docs for the form.LOAD action again, your json stricture is not quite correct.

deblasio
10 Sep 2008, 9:30 AM
Thanks for the quick response, I now see that the string should have been formatted as :{success: true, data: {idcode: '1'}}