Returning a JSON object from PHP in AJAX call?

前端 未结 3 512
旧巷少年郎
旧巷少年郎 2021-01-02 11:30

Here\'s my PHP code called during jQuery AJAX call:



        
3条回答
  •  -上瘾入骨i
    2021-01-02 11:59

    json_encode accepts objects, so there's no need to do that automatic array-building.:

    $row = $result->fetch_object();
    echo json_encode($row);
    

    It's as simple as that!

提交回复
热议问题