【发布时间】:2017-01-31 20:10:55
【问题描述】:
最后我从 PHP 中得到了一些输出,而不仅仅是“数组”这个词。这花了我一天的时间,啊啊啊啊。
(解决方法见here)
所以这是来自 XMLHTTP 请求(到 PHP)的返回值,通过 JS 中的回调。我用 PHP 中的print_r 得到了它。
我在这里发布了结果的 sn-p。 我的新问题:
- 这个数据结构是由什么组成的?
-
如何从这个结构中取出元素,例如 CourseID(在 JS 中)?
[0] => Parse\ParseObject Object ( [serverData:protected] => Array ( [CourseID] => DEMO2 [EndDate] => DateTime Object ( [date] => 2017-03-31 10:26:00.000000 [timezone_type] => 2 [timezone] => Z ) [InfoTitle1] => Welcome [InfoText1] => Welcome to your course, called "sense & sales". [Admin] => Remco@Demo1 )
我的 PHP 代码是
function getGroups(){
$query = new ParseQuery("CourseInfo");
$query->equalTo("Admin", "Remco@Demo1");
$results = $query->find();
// echo $results // this lead to the string "array"
//print_r($results); // this leads to the complicated array
//echo "<script>\r\n var phpOutput = " . json_encode($results) . ";\r\n console.log(phpOutput);\r\n</script>";
// this leads to [{},{}];
}
【问题讨论】:
-
可能类似于
$data[0]->CourseId。 -
您需要在标记或 AJAX 调用中序列化您的数组。
-
您已标记此 JavaScript,但我没有在问题中看到任何 JavaScript。而且这个问题应该独立存在,不需要别人回头看看你的另一个问题。
标签: javascript arrays