Title: No messages box
Post by: alphasil on February 06, 2015, 05:51:39 AM
Hi Another small problem I can't get any message(alert or message) when i insert a record into my database This is my function function atividadeNova(){ $('#fm').form('submit',{ url: 'nova_atividade.php', onSubmit: function(){ return $(this).form('validate'); }, success: function(result){ var result = eval('('+result+')'); if (result.errorMsg){ $.messager.show({ title: 'Erro', msg: result.errorMsg }); } else { $('#dlg').dialog('close'); // close the dialog $('#dg').datagrid('reload'); // reload the user data } } }); }
And this is my php echo json_encode(array( 'idativade' => mysql_insert_id(), 'nomecargo' => $nomecargo, 'atividade' => $atividade, 'data' => $data, 'hora' => $hora, 'local' => $local, 'inter' => $inter, 'notas' => $notas, 'success': true, "message": 'Registo gravado.' )); } } } else { echo json_encode(array('errorMsg'=>'Erro no registo.')); } ?>
I want to have a message telling the result....but even when json is false i don't have any message box Any help please?
Title: Re: No messages box
Post by: stworthy on February 06, 2015, 05:23:36 PM
Please confirm if the returned result is correct, try the code below: success: function(result){ var result = eval('('+result+')'); console.log(result); if (result.errorMsg){ $.messager.show({ title: 'Erro', msg: result.errorMsg }); } else { $('#dlg').dialog('close'); // close the dialog $('#dg').datagrid('reload'); // reload the user data $.messager.show({ title: 'Info', msg: result.message }); } }
Title: Re: No messages box
Post by: alphasil on February 09, 2015, 10:09:55 AM
Done
Thnak you for your help
|