Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/235.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 如何在PHP中使用Ajax从网站(如IMDB)获取数据_Javascript_Php_Jquery_Ajax_Imdb - Fatal编程技术网

Javascript 如何在PHP中使用Ajax从网站(如IMDB)获取数据

Javascript 如何在PHP中使用Ajax从网站(如IMDB)获取数据,javascript,php,jquery,ajax,imdb,Javascript,Php,Jquery,Ajax,Imdb,我正在开发一个恐怖电影网站。我想从IMDB获取数据。我需要使用Ajax异步获取数据。我的代码不能正常工作 电影信息未出现在carousal中。 获取数据的html文件: <?php require_once('functions.php'); $triangle = getMovieInfo('triangle'); $Predestination = getMovieInfo('Predestination'); $silen

我正在开发一个恐怖电影网站。我想从IMDB获取数据。我需要使用Ajax异步获取数据。我的代码不能正常工作

电影信息未出现在carousal中。 获取数据的html文件:

  <?php
       require_once('functions.php'); 
       $triangle = getMovieInfo('triangle');
       $Predestination = getMovieInfo('Predestination');
       $silence_of_the_lambs = getMovieInfo('The Silence of the Lambs');
       $shutter_island = getMovieInfo('Shutter Island');
    ?>
    <br>
  <!-- Text which has greater value -->
    <div>
      <div class = "row">
        <div class="alert alert-success text-center" role="alert"><h3>If you are looking for a site, where you can see the list of all verified thrillers, then you are at the right place.</h3></div>
      </div>
    </div>
    <!-- slider for the home page -->

        <div class="container">

      <div class="row">
        <div class = "col-md-6 col-lg-6 col-sm-6">
          <div id="myCarousel" class="carousel slide" data-ride="carousel">
            <!-- Indicators -->
            <ol class="carousel-indicators">
              <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
              <li data-target="#myCarousel" data-slide-to="1"></li>
              <li data-target="#myCarousel" data-slide-to="2"></li>
              <li data-target="#myCarousel" data-slide-to="3"></li>
            </ol>

            <!-- Wrapper for slides -->
            <div class="carousel-inner" role="listbox">

              <div class="item active">
                <?php  echo "<img src=\"$triangle->Poster\">"; ?>
                <!-- <span> <?php echo "Plot : ".$triangle->Plot; ?> </span> -->
              </div>
              <div class="item">
                <?php  echo "<img src=\"$silence_of_the_lambs->Poster\">"; ?>
                 <!-- <span> <?php echo "Plot : ".$silence_of_the_lambs->Plot; ?> </span> -->
              </div>
              <div class="item">
                <?php  echo "<img src=\"$Predestination->Poster\">"; ?>
                 <!-- <span> <?php echo "Plot : ".$Predestination->Plot; ?> </span> -->
              </div>
              <div class="item">
                <?php  echo "<img src=\"$shutter_island->Poster\">"; ?>
                 <!-- <span> <?php echo "Plot : ".$shutter_island->Plot; ?> </span> -->
              </div>
            </div>

            <!-- Left and right controls -->
            <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
              <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
              <span class="sr-only">Previous</span>
            </a>
            <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
              <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
              <span class="sr-only">Next</span>
            </a>
          </div>  
          </div>
          <div class ="col-md-6 col-lg-6 col-sm-6">
             <div class="well">
              <div class="thriller">
                  <h3>What is a thriller movie?</h3>
                  <h4>If the genre is to be defined strictly, a genuine thriller is a film that rentlessly pursues a single-minded goal - to provide thrills and keep the audience cliff-hanging at the 'edge of their seats' as the plot builds towards a climax.</h4>
                  <h4>
                   Believe me, I love watching thriller movies more than anything. These movies are real movies, where you can't guess the last scene. I enjoyed a lot of thriller movies and then thought to make a site, where you can easily watch a movie.
                  </h4>
              </div>
             </div>
          </div>
        </div>

    </div>
我的java脚本文件是:

$(document).ready(function() 
{
  $("#home").click(function(event)
  {
      alert("home is clicked");
      $('#contents').load('home.html');
  });


});

请帮我解决这个问题。

您的文件需要是.php,而不是.html,因为您在代码中使用的是php


不过,别担心,HTML仍将被正常解析。

“我的代码工作不正常。”真的吗?关于一些具体的问题、错误消息等呢?我正在添加一个屏幕截图。如果您真的摆脱了所有这些
?什么也没有发生,内容id包含:尝试更改您的报价位置:
回显“海报\>”
$(document).ready(function() 
{
  $("#home").click(function(event)
  {
      alert("home is clicked");
      $('#contents').load('home.html');
  });


});