Hi @kovuruanil96,
Please copy paste the code instead of sharing the screenshot of the code so that we can help you out.
<!DOCTYPE html>
<html>
<head>
<title> movie finder </title>
<link rel="stylesheet" type="text/css" href="intern.css">
</head>
<body>
<div class= "title">
MOVIE FINDER
<img src="netflix_logo.png" class="nlogo">
<img src="ama.png" width="180px">
</div>
<div class="search_box">
<div class="movie">
<input type="search" id="movie_name" placeholder="Search movie" width="300px">
<button>submit</button>
</div>
</div>
<p id=" output">finding movies</p>
<script type="text/javascript">
function search_machine(){
document.getElementById("output").fontSize="100px";
document.getElementById("output").style.color="#93B782";
movie_name=document.getElementById("movie_name".value)
httpRequest=new XMLHttpRequest();
url="http://www.omdbapi.com/apikey.aspx?VERIFYKEY=8be18c83-ce44-417b-b9b2-3bd80d11db0b " + movie_name;
httpRequest.open("GET",url);
httpRequest.send();
httpRequest.onreadystatechange= function(){
if (this.readyState == 4 && this.status == 200)
{
console.log(this.responseText);
user_data= JSON.parse(this.responseText);
document.getElementById("output").innerHTML= movies_name;
}
* List item
</script>
</body>
</html>
Hi @kovuruanil96,
Please check the code below. Update the API Key in the URL
<!DOCTYPE html>
<html>
<head>
<title> movie finder </title>
<link rel="stylesheet" type="text/css" href="intern.css"> </head>
<body>
<div class="title"> MOVIE FINDER <img src="netflix_logo.png" class="nlogo"> <img src="ama.png" width="180px"> </div>
<div class="search_box">
<div class="movie">
<input type="search" id="movie_name" placeholder="Search movie" width="300px">
<button onclick="search_machine()">submit</button>
</div>
</div>
<p id="output">finding movies</p>
<script type="text/javascript">
function search_machine() {
document.getElementById("output").style.fontSize = "100px";
document.getElementById("output").style.color = "#93B782";
movie_name = document.getElementById("movie_name").value
httpRequest = new XMLHttpRequest();
url = "http://www.omdbapi.com/?apikey=8be18c83-ce44-417b-b9b2-3bd80d11db&t=" + movie_name;
httpRequest.open("GET", url);
httpRequest.send();
httpRequest.onreadystatechange = function() {
if(this.readyState == 4 && this.status == 200) {
console.log(this.responseText);
user_data = JSON.parse(this.responseText);
document.getElementById("output").innerHTML = movies_name;
}
}
}
</script>
</body>
</html>
sir i updated the API key and run the code again .it is not working .Can you please tell if there is something wrong with my code .
Hi @kovuruanil96,
- Your request url was incorrect
- You have used movies_name instead it will be user_data.Title;
Check the response from the omdbapi in console.
The code would be
<!DOCTYPE html>
<html>
<head>
<title> movie finder </title>
<link rel="stylesheet" type="text/css" href="intern.css"> </head>
<body>
<div class="title"> MOVIE FINDER <img src="netflix_logo.png" class="nlogo"> <img src="ama.png" width="180px"> </div>
<div class="search_box">
<div class="movie">
<input type="search" id="movie_name" placeholder="Search movie" width="300px">
<button onclick="search_machine()">submit</button>
</div>
</div>
<p id="output">finding movies</p>
<p id="plot"></p>
<script type="text/javascript">
function search_machine() {
document.getElementById("output").style.fontSize = "100px";
document.getElementById("output").style.color = "#93B782";
movie_name = document.getElementById("movie_name").value
httpRequest = new XMLHttpRequest();
url = "http://www.omdbapi.com/?apikey=595ad7d7&t=" + movie_name;
httpRequest.open("GET", url);
httpRequest.send();
httpRequest.onreadystatechange = function() {
if(this.readyState == 4 && this.status == 200) {
console.log(this.responseText);
user_data = JSON.parse(this.responseText);
document.getElementById("output").innerHTML = user_data.Title;
document.getElementById("plot").innerHTML = user_data.Plot;
}
}
}
</script>
</body>
</html>