Welcome Guest, Not a member yet? Register   Sign In
JSON return string ajax
(This post was last modified: 02-01-2021, 02:19 PM by ferb.)

I send form by post, and response will be a json encode

this return controller

$msg = ["tipo" => 'danger',
"icon" => 'fa fa-times',
"msg" => 'Email no encontrado.'];

return $this->response->setJSON($msg);

but retrivied and string

i using codeigniter 4.1.1

(This post was last modified: 02-02-2021, 02:13 AM by demyr.)

You need Json stringify. Please look for it on internet

An example :

PHP Code:
     $.each($('#holder').serializeArray(), function() {
    answer[this.name] = this.value;
var answers JSON.stringify(answernull2);
          url "<?php echo base_url('your-controller-and-method');?>",


Theme © iAndrew 2016 - Forum software by © MyBB