este es el codigo
Código PHP:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="ext-3.2.1/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="resources/style.css" />
<script type="text/javascript" src="ext-3.2.1/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="ext-3.2.1/ext-all.js"></script>
<script type="text/javascript">
var form = new Ext.FormPanel({
labelWidth : 70,
url : 'pagina.php',//1
defaults : {
xtype : 'textfield'//2
},
items : [
{
fieldLabel : 'nombre',
id : 'nombre' //3
}, {
fieldLabel : 'apellido',
id : 'apellido'
}],
fbar : [{//4
xtype : 'button', iconCls: 'guardar', tooltip: 'Guardar los datos',
handler : function(){
form.getForm().submit({
method : 'POST',
params : {operacion : 'agregar'},//5
waitTitle : 'Conectando',
waitMsg : 'Enviando datos...',
success : function(){//6
win.close();
var store = Ext.getCmp('grilla').getStore();
store.reload();
},
failure : function(form, action){//7
if (action.failureType == 'server'){
respuesta = Ext.util.JSON.decode(action.response.responseText);
Ext.MessageBox.show({
title : 'Error',
msg : respuesta.errors.razon,
buttons : Ext.MessageBox.OK,
icon : Ext.MessageBox.ERROR
});
} else {
Ext.MessageBox.show({
title : 'Error',
msg : 'Faltan datos!',
buttons : Ext.MessageBox.OK,
icon : Ext.MessageBox.ERROR
});
}
}
});
}
}]
});
var win = new Ext.Window({
title : 'agregar',
iconCls : 'icono',
layout : 'fit',
width : 280,
height : 120,
closable : true,
resizable : false,
border : true,
modal : true,
constrain : true,
items : form
});
</script>
</head>
<body>
</body>
</html>