PDA

View Full Version : form submit is ok, but the success msg don't show



bero
26 Jan 2011, 2:25 PM
I have a form with a button that submit to a php form with a mysql_query.
The query works fine, but i can't figure how to get the success and failure msgbox....

also i don't understond wich one Ext wil take (the one from the .js of from the .php file?)
first off all.. The Code!

The Button in my .js


buttons: [{
text: 'Toevoegen',
handler: function() {
toevoegen_form.getForm().getEl().dom.action = 'output.php';
toevoegen_form.getForm().getEl().dom.method = 'POST';
toevoegen_form.getForm().submit({
success: function() {
Ext.msg.alert('GOED', 'done..');
},
failure: function() {
Ext.msg.alert('FOUT', 'NOT done..');
}
});

}
}]

(part of) the php file


$result = mysql_query($query);
if(!$result){
echo "{success: false}";

}
else {
echo "{success: true} ";
}



And here the firebug log, showing the php post and the success msg...

INSERT INTO data (serienaam, catagorie, gzb, figuur, h_a) VALUES ('79', '2', '0', '0', '908.00, '88.00'){success: true}

there is also a test file i can show live but i wait with that till its realy needed..


Please help!!

dduffy
28 Jan 2011, 3:29 AM
can you show an image of your Firebug console; example shown above is not Firebug, plus your JSON is strictly speaking not correct use http://www.jsonlint.com/ to validate your JSON code.

bero
31 Jan 2011, 1:20 AM
The image above is the 'response' in firebug.
Here are the Headers and Console images:

24513
24514

ExtJSBeginner
31 Jan 2011, 4:45 AM
i have no clue of php but what do you exactly answer the client after having your query executed?
do you send back something over http? because as far as I understand the http status is examined
for calling the success and failure callbacks...

Graveworm
31 Jan 2011, 5:00 AM
try



$arr = array ('success' => true);

echo json_encode($arr);


i think your quotes are not correct.


echo "{'success': false}";

bero
31 Jan 2011, 2:40 PM
Thnx Graveworm! you'r answer was correct! It works fine now!