这是我得到的JSON响应。 我正在使用php中的java脚本搜索此响应中的名称,bio,specialism。 使用javascript搜索代码。
Array(
[contense] => Array
(
[0] => Array
(
[ref] => Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
[5] => 6
)
[name] => Array
(
[0] => James
[1] => Bob
[2] => Dan
[3] => Olive
[4] => Jess
[5] => Tim
)
[specialism] => Array
(
[0] =>
[1] =>
[2] =>
[3] =>
[4] =>
[5] =>
)
[bio] => Array
(
[0] => About me
[1] => About me
[2] => About me
[3] => About me
[4] => About me
[5] => About me
)
[picture] => Array
(
[0] => http://coolbeanslive.co.uk/unity/wp-content/uploads/2015/06/trainer-1.png
[1] => http://coolbeanslive.co.uk/unity/wp-content/uploads/2015/06/trainer-2.png
[2] => http://coolbeanslive.co.uk/unity/wp-content/uploads/2015/06/trainer-3.png
[3] => http://coolbeanslive.co.uk/unity/wp-content/uploads/2015/06/trainer-4.png
[4] => http://coolbeanslive.co.uk/unity/wp-content/uploads/2015/06/trainer-4.png
[5] => http://coolbeanslive.co.uk/unity/wp-content/uploads/2015/06/trainer-4.png
)
)
)
) 搜索文本框中的按键搜索。
这是我的javascript代码。
var xmlhttp = new XMLHttpRequest(); var url = "url";
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
myFunction(xmlhttp.responseText);
}
}xmlhttp.open("GET", url, true); xmlhttp.send(); function myFunction(response) {var arr = JSON.parse(response); //...code for serach }
答案 0 :(得分:0)