This article mainly introduces the method of php implementing the app interface and returning json data. Interested friends can refer to it. I hope it will be helpful to everyone.
Step one: conn.PHPfile, used to connectdatabaseand define the interface format, the code is as follows :
$code, 'message'=>$message, 'data'=>$data ); //输出json echo json_encode($result); exit; } } ?>
Step 2: text.php, used to convert the data in the database into a json string and output:
The third step: text.html, ajax loads json data and displays:
Related recommendations:
getJSON() asynchronously requests the server to returnjsonformat data (graphic tutorial)
JSON object definition in JS Detailed explanation of the value implementation steps
Json-lib processing solution when using frameworks such as Ajax or Easyui (graphic tutorial)
The above is the detailed content of PHP method to implement app interface and return json data. For more information, please follow other related articles on the PHP Chinese website!