0
這是我得到的JSON響應。 我在php中使用java腳本在這個響應中搜索名稱,生物,專業。 使用javascript搜索代碼。在php中搜索關鍵字的JSON響應
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
)
)
)
) serach on searchpress in search textbox。
這裏是我的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 }
爲什麼downvoted?請留下評論.... – Akki619