PDA

View Full Version : simple login form with Ext.JSON.decode



jakobo
7 May 2012, 12:29 AM
i am trying to create a simple login function towards a php script where i JSON encode a string


PHP code:
$jsonString = json_encode('success');
echo $jsonString;

the i use Ext.JSON.decode to parse the result like this in my logincontroller:


var result = Ext.JSON.decode(response.responseText);
if (result.success) {
Ext.Msg.alert(working);
}
else{
Ext.Msg.alert(result);
}


and i get a Ext.Msg.alert saying success ;-)
anyone that can tell me what i am doing wrong here ? :-)

mitchellsimoens
9 May 2012, 7:07 AM
Have you inspected what the result param is? I would have expected an error decoding a string.

jakobo
9 May 2012, 7:17 AM
i changed it to
if (result == 'success') {
and that seems to be working :-)