JSON URL: http: //en.wikipedia.org/w/api.php?format =json&action=opensearch&search= "+ str +"&namespace = 0&suggest =
ここで、「str」は、たとえばstr ='nas'の場合は2〜3文字で、JSON URL: http: //en.wikipedia.org/w/api.php ?format=json&action=opensearch&search=nas&namespace=0&suggest=
すべての結果を取得して、これらの結果をテーブルに入れたい
私はAJAX、JSON、JQUERYを試しました。これを行うための作業コードを誰かに送ってもらえますか。
私のダミーコード:-
<!DOCTYPE html>
<html>
<head>
<script type="application/javascript">
function FillSearchBox(str)
{
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status=200)
{
//Pointer never Comes in this Section (If I Debuug I got xmlhttp.status=0 every time)
var JSONObject = JSON.parse(xmlhttp.responseText);
}
}
var strr= "http://en.wikipedia.org/w/api.php?format=json&action=opensearch&search="+str+"&namespace=0&suggest=";
xmlhttp.open("GET",strr,true);
xmlhttp.send();
}
</script>
</head>
<body>
<form>
<input type="text" name="wikisearch" id="" onkeyup="FillSearchBox(this.value)" />
</form>
<!-- add Table or Div Here -->
</body>
</html>