PDA

View Full Version : Form submit + PHP



scheide
17 Jul 2009, 9:31 AM
Hello,

I have a FormPanel with a submit button:



...
buttons: [{
text: 'Consultar',
handler: function() {
if (panel.getForm().isValid()) {
panel.getForm().submit({
url: 'xxx.php',
method: 'POST',
waitTitle: 'Aguarde',
waitMsg: 'Processando...',
success: function(form, action) {
alert('ok');
div.update(action.response.responseText);
},
failure: function(form, action) {alert('erro');}
});
}
}
...


xxx.php:


<?php
echo "teste";
?>


firebug error:
teste is not defined
eval()()w2zD3TNu...2FQ%3D%3D (linha 1)
parse()()ext-all-debug.js (linha 11489)
handleResponse()(Object tId=2 status=200 statusText=OK responseText=teste)ext-all-debug.js (linha 51562)
processResponse()(Object tId=2 status=200 statusText=OK responseText=teste)ext-all-debug.js (linha 51449)
success()(Object tId=2 status=200 statusText=OK responseText=teste)ext-all-debug.js (linha 51531)
handleResponse()ext-all-debug.js (linha 9285)
handleTransactionResponse()ext-base.js (linha 111)
handleReadyState()()

Anybody could help me?
[]'s

tryanDLS
17 Jul 2009, 9:52 AM
Have you read the documentation on what you need to return from a form submit? Certainly not a string of jibberish.

scheide
17 Jul 2009, 10:35 AM
Do I always have to return a JSON to a submit form?
Thanks.

httpdotcom
17 Jul 2009, 12:22 PM
You should always return the result in a format Ext is designed to understand, including a success response.

PHP:

<?
$array = array( "success" => true, "data" => array( "msg" => "teste" ) ) ;
echo json_encode( $array ) ;
?>

returns { "success": true, "data": { "msg": "teste" } }


Then, use action.response.data.msg in your success block.