Javascript-an ajax request

Source: Internet
Author: User
First, send an ajax request to getPics. The code length is as follows: {code...} And then getPics. php is as long as this & amp; lt ;? Php {code ...}? & Amp; gt; I can correctly return the data obtained from www.wookmark.com during a local test, but when I put the code on github, I will return...
  • First, send an ajax request to getPics. The code length is as follows:

      function getList(){       ajax('get', 'getPics.php', 'cPage=' + iPage, function(data){               var data=JSON.parse(data);               if(!data.length){                   return;               }               for(i=0;i
        
  • Then, the length of getPics. php is like this.

       header('Content-type:text/html; charset="utf-8"');   $cpage = isset($_GET['cpage']) ? $_GET['cpage'] : 1;   $url = 'http://www.wookmark.com/api/json/popular?page=' . $cpage;   $content = file_get_contents($url);   $content = iconv('gbk', 'utf-8', $content);   echo $content;

    ?>

    During the local test, I was able to correctly return the data obtained from www.wookmark.com, but when I put the code on github, the returned data became the string form of the PHP file content.

    What's the problem?

Reply content:
  • First, send an ajax request to getPics. The code length is as follows:

      function getList(){       ajax('get', 'getPics.php', 'cPage=' + iPage, function(data){               var data=JSON.parse(data);               if(!data.length){                   return;               }               for(i=0;i
         
  • Then, the length of getPics. php is like this.

       header('Content-type:text/html; charset="utf-8"');   $cpage = isset($_GET['cpage']) ? $_GET['cpage'] : 1;   $url = 'http://www.wookmark.com/api/json/popular?page=' . $cpage;   $content = file_get_contents($url);   $content = iconv('gbk', 'utf-8', $content);   echo $content;

    ?>

    During the local test, I was able to correctly return the data obtained from www.wookmark.com, but when I put the code on github, the returned data became the string form of the PHP file content.

    What's the problem?

Will github help you parse and run php?

Github only stores code for you, but does not execute specific code.

Github page does not support PHP file running. You have to use your own server.

How can I answer this question .?

This is a great question.

Github is where code is hosted and does not provide running services. You need to put it in your php environment.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.