mardi 3 octobre 2017

Parsing the data from controller in ajax

Controller is sending message to ajax call. I want to display translated message on error using ajax.

Controller:

(($to <= $from) && ($statistics > $from)):
 header('Content-Type: application/json', true, 400);
 die(json_encode(["error"=> true, "message" => trans('servicereports.errors.combine')]));

I would like to parse my json to receive only the message in trans.

what to put in ajax code?

 $.ajax({
   type: 'POST',
   url: '',
   cache: false,
   data: $(this).serialize(),
   success: function(data) {
       $('#form').html("<thead><tr><td>OK</td></tr>");
   },
   error: function(result){ 
        /* Custom message I want to send*/       
   } });



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire