Correct way to read 'echo json_encode( )' from JQuery

后端 未结 5 1254
醉梦人生
醉梦人生 2021-01-05 10:09

I am using: echo json_encode($Response); to send an Associative array back to JQuery Ajax. Whenever I try to read each ID key value I get an undefined value. Please help me

5条回答
  •  清歌不尽
    2021-01-05 10:16

    You should set the mime type aswell, wich, according to this question is application/json. Then jQuery will understand the answer is a json element. To do it, you'd do the following:

    header('Content-Type: application/json');
    

    In your UpdateEditAStudent.php before printing anything.

提交回复
热议问题