【发布时间】:2017-07-02 11:11:50
【问题描述】:
我有这段代码应该将其结果转换为 json。 我想用js获取数组并打印出来。
$db = new PDO('mysql:host=localhost;dbname=Contact', 'root', '');
$statement=$db->prepare("SELECT * FROM myfeilds");
$statement->execute();
$results=$statement->fetchAll(PDO::FETCH_ASSOC);
$json=json_encode($results);
我该怎么做?
$(document).ready(function() {
$.ajax({
type : 'POST',
url : 'server.php',
success : //........
});
});
【问题讨论】:
标签: javascript json ajax