【发布时间】:2017-06-07 03:50:03
【问题描述】:
我是 http 请求和 php 的新手。我有一个http:
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var doc = xmlhttp.response;
myFunc(doc);
}
};
xmlhttp.open("GET",some.php",true);
xmlhttp.responseType = "document";
xmlhttp.send(null);
php文件:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body id="idk">
<?php
include("include1.inc");
include_once("include2.inc");
$cxn = mysqli_connect($host,$user,$passwd,$dbname) or die("Could not connect to the server at this time.");
$table = 'table';
$data = retrieveData($table, $cxn);//selects data from mysql db return array
var_dump($data);
?>
</body>
</html>
如何从数据库中获取保存数组的数据变量? 当我转储或打印变量时,数组被传递给`responseText。有没有更雄辩的方法来抓住那个数组?
【问题讨论】:
-
字体颜色表示您忘记了引号。
-
xmlhttp.open("GET",some.php",true);=>xmlhttp.open("GET","some.php",true);
标签: javascript php ajax xmlhttprequest