Post JSON to Codeigniter controller

后端 未结 12 1066
鱼传尺愫
鱼传尺愫 2020-12-30 05:03

I am trying to receive and parse a JSON object sent in a POST request using Codeigniter but I cannot \"find\" it.

This is my controller code:

public          


        
12条回答
  •  北海茫月
    2020-12-30 05:16

    Try this instead

    $json = $this->input->post('data');
    $json = stripslashes($json);
    $json = json_decode($json);
    print_r($json);
    

    You need to pass in the key of the data variable you want from the post array as an argument to post()

提交回复
热议问题