Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/400.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用AJAX加载IMDB电影信息_Javascript_Php_Jquery_Ajax - Fatal编程技术网

Javascript 如何使用AJAX加载IMDB电影信息

Javascript 如何使用AJAX加载IMDB电影信息,javascript,php,jquery,ajax,Javascript,Php,Jquery,Ajax,我有这个代码来获取IMDB电影信息 我有一个网站可以下载免费电影 关于一系列电影的信息,我需要使用IMDB API,我使用了下面的代码,但是在完成之前,它会刷新我的页面并发布我的文章,所以我需要使用Ajax获取信息,我使用了下面的代码 <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Get IMDB Inf

我有这个代码来获取IMDB电影信息 我有一个网站可以下载免费电影

关于一系列电影的信息,我需要使用IMDB API,我使用了下面的代码,但是在完成之前,它会刷新我的页面并发布我的文章,所以我需要使用Ajax获取信息,我使用了下面的代码

<html>

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>Get IMDB Info</title>
</head>

<body>
  <center>
    <form method="post">
      Address : <input type="text" name="url" size="50"   placeholder="Example: http://www.imdb.com/title/tt1340138" dir="ltr"><br><br>
      <input type="submit" value="Get">
    </form>
  </center>
  <br><br>
  <?php 
    error_reporting(E_ERROR | E_PARSE);
    if(empty(!$_POST['url'])){
        echo '<div dir="ltr">';
        function IMDB ($url){
            preg_match("/tt\\d{7}/i", $url, $Id);
            $Get = file_get_contents('http://www.omdbapi.com/?i='.$Id[0]);
            $json = json_decode($Get,true);
            return $json;
        }

        $Response = IMDB($_POST['url']);
        if(!$Response){
            die ('خطا!');
        }
        echo "Title: ".$Response['Title'].'<br>'.
        "Year: ".$Response['Year'].'<br>'.
        "Rated: ".$Response['Rated'].'<br>'.
        "Released: ".$Response['Released'].'<br>'.
        "Runtime: ".$Response['Runtime'].'<br>'.
        "Genre: ".$Response['Genre'].'<br>'.
        "Director: ".$Response['Director'].'<br>'.
        "Writer: ".$Response['Writer'].'<br>'.
        "Actors: ".$Response['Actors'].'<br>'.
        "Plot: ".$Response['Plot'].'<br>'.
        "Language: ".$Response['Language'].'<br>'.
        "Country: ".$Response['Country'].'<br>'.
        "Awards: ".$Response['Awards'].'<br>'.
        "Poster: ".$Response['Poster'].'<br>'.
        "Metascore: ".$Response['Metascore'].'<br>'.
        "imdbRating: ".$Response['imdbRating'].'<br>'.
        "imdbVotes: ".$Response['imdbVotes'].'<br>'.
        "imdbID: ".$Response['imdbID'].'<br>'.
        "Type: ".$Response['Type'].'<br>'.
        "Response: ".$Response['Response'].'<br>'.
        '</div>'
        ;


    }
    ?>
</body>

</html>

获取IMDB信息
地址:




你能试试这个吗-

$(文档).ready(函数(){
$('imdbInfoForm')。关于('submit',函数(e){
e、 预防默认值();
var arr=$('#imdbUrl').val().match(/tt(\d+/);
var imdbId=arr[0];
$.ajax({
url:“http://www.omdbapi.com/?i=“+imdbId,
成功:功能(数据){
$('#result').html('Title:'+data.Title+'
'+'年份:'+data.Year+'
'+'评级:'+data.Rated+'
'+'发布:'+data.Released+'
'+'运行时:'+data.Runtime+'
'+'流派:'+data.Genre+'
'+'导演:'+data.Director+'
'+'编剧者:'+data.Writer+'
'+'演员:'+data.Actors+'
''Plot:'
“+”语言:“+data.Language+”
“+”国家:“+data.Country+”
“+”奖项:“+data.Awards+”
“+”海报:“+data.Poster+”
“+”元分数:“+data.Metascore+”
“+”imdbRating:“+data.imdbRating+”
“+”imdbvots:“+data.imdbvots+”
“+”imdbID:“+data.imdbID+”

“+”类型:“+data.Type+”>“+”响应:“+data.Response+”
”; } }) .完成(功能(数据){ if(console&&console.log){ log(“数据样本:”,data.slice(01000)); } }); }) });

获取IMDB信息
地址:


你能再解释一下问题的最后一部分吗?你自己试过吗?@dipak chavda例如,我需要将imdb链接放到输入框中,然后按GET按钮,然后使用ajax从api获取信息(无需重新加载页面)和display分开输入,例如一个输入,另一个输入到语言和更多…你可以在pastebin中找到上述代码的工作副本。如何将这些信息放到许多输入中,例如,语言txt语言的名称txtname和…@Samuel-J-Mathewits工作正常,但在wordpress上不工作,因为我不知道t在哪里他是js最好的地方files@zolfaghari将js-in-script标记放在footer中您确定您使用的是相同的html和js吗