Title: Laravel show json response dialog box Post by: dewan on January 25, 2019, 08:49:31 PM Hi
Is it possible to show the json response. Like when i delete the record i want to show the return json response $(function(){ $('#tt').edatagrid({ url:"sales_invoice", saveUrl: '', updateUrl: '', destroyUrl: 'invoice_destroy', onDblClickRow: function (index,row) { window.open("invoice_detail/"+row.invoice_id,"_blank") } }); }); public function destroy(Request $request) { $data = InvoiceJournal::where('id', $request->id)->delete(); if ($data) { return response()->json(['message'=>'Deleted Successfully'],200); } return response()->json(['message'=>'error while delete record'],200); } how can i show this response. Thank you. Title: Re: Laravel show json response dialog box Post by: stworthy on January 26, 2019, 06:55:47 PM You can custom the 'poster' function to retrieve any data from the server. Please look at this code.
Code: <script> $.extend($.fn.edatagrid.defaults, { poster: function(url, data, success, error){ $.ajax({ type: 'post', url: url, data: data, dataType: 'json', success: function(data){ if (data.row){ success(data.row); } else { success(data); } if (data.message){ $.messager.alert('Message', data.message); } }, error: function(jqXHR, textStatus, errorThrown){ error({ jqXHR: jqXHR, textStatus: textStatus, errorThrown: errorThrown }); } }); } }) </script> You can return the json data to the browser. Code: {"row":{...},"message":"..."} If the 'message' exists, the message alert will display. |