omdbapi.Soからムービー情報を取得しようとしていますが、omdb api.Butを使用してimdbからデータを抽出しています。私はそれを達成するのですか?抽出したJsonデータをデータベースにインポートするには
この
<form>
<input type="text" id="tst"/>
<input type="button" value="search" id="btn"/>
</form>
<table class="table table-hover" id="imdb">
<thead>
<tr>
<th>Poster</th>
<th>Title</th>
<th>Year</th>
<th>Rated</th>
<th>Runtime</th>
<th>Genre</th>
<th>Director</th>
<th>Actors</th>
<th>Plot</th>
</tr>
</thead>
<tbody></tbody>
</table>
のように私のコードを見てこれはあなたが同じ関数内で場所(あなたのAPIレスポンスからJSONオブジェクトを作成することができ、私は映画情報
$(document).ready(function() {
$('#btn').click(function(){
var imdbid=$('#tst').val();
var url = "http://www.omdbapi.com/?i="+imdbid+"&plot=short&r=json"
$.ajax({
url:url,
dataType:'json',
success:function (json) {
var tr;
tr = $('<tr/>');
tr.append("<td><img src=" + json.Poster + " width='200' height='297'></td>");
tr.append("<td>" + json.Title + "</td>");
tr.append("<td>" + json.Year + "</td>");
tr.append("<td>" + json.Rated + "</td>");
tr.append("<td>" + json.Runtime + "</td>");
tr.append("<td>" + json.Genre + "</td>");
tr.append("<td>" + json.Director + "</td>");
tr.append("<td>" + json.Actors + "</td>");
tr.append("<td>" + json.Plot + "</td>");
$('#imdb').append(tr);
}
})
})
});
APIに接続してデータベースに保存するか、クライアント側から情報を受け入れてデータベースに保存するサーバー側スクリプトを記述する必要があります。 –
実際に達成したいことはそれは私がIMDb IDを入れて、それがやっている映画の細部を検索し、ユーザーがいくつかの追加情報を追加し、APIから抽出したデータと一緒に私の電話のスクリプトにデータを送ることを許可したい。すべてのプロセスを知るために –
apiからデータを取得してユーザー入力を受けた後、このデータをサーバーに投稿するためのajax呼び出しを作成し、このデータをデータベースに挿入できるサーバー側スクリプトを作成する必要があります。 –