-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
65 lines (58 loc) · 1.81 KB
/
script.js
File metadata and controls
65 lines (58 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
var obj={};
var l=1;
$(document).ready(function(){
$(".abc").click(function(){
var table = document.getElementById("myTable");
for(var k=table.rows.length-1;k>0;k--)
{
table.deleteRow(k);
}
l=1;
var title=$(".textClass").val();
// $.getJSON("http://www.omdbapi.com/?s="+a, function(result){
// $.each(result, function(i, field){
// // $(".body-Section").append(JSON.stringify(field) );
// if(i=="Search")
// {
// obj=JSON.stringify(field);
// }
// });
$.ajax({
type:'GET',
url: 'http://www.omdbapi.com/?s='+title,
dataType:'json',
success: function(jsonData)
{
// obj=JSON.stringify(jsonData);
// //console.log(obj);
// var json=$.parseJSON(obj);
json=jsonData.Search;
$(json).each(function(i,val){
$.each(val,function(k,v){
$(".table-Section").css('display','block');
if(l!=json.length)
{
var table = document.getElementById("myTable");
var row = table.insertRow(l);
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
var cell3 = row.insertCell(2);
var cell4 = row.insertCell(3);
var cell5 = row.insertCell(4);
cell1.innerHTML = json[l].Title;
cell2.innerHTML = json[l].Year;
cell3.innerHTML = json[l].imdbID;
cell4.innerHTML = json[l].Type;
cell5.innerHTML = "<img src="+json[l].Poster+">";
l=l+1;
}
});
});
},
error: function()
{
alert('Error in Loading');
}
});
});
});