0
我在我的HTML代碼如下。我無法保持警覺,無法將任何東西寄回給我。我不能得到這個Ajax調用工作,沒有JSON輸出
$.ajax({
url:"proxy.php?url=http%3A%2F%2Fapi.rottentomatoes.com%2Fapi%2Fpublic%2Fv1.0%2Flists%2Fmovies%2Fupcoming.json%3Fpage_limit%3D16%26page%3D1%26country%3Dus%26apikey%3Dk4uaze4937mw3hf82upstxqw%0A",
type:'GET',
dataType:"json",
success:function(data){var title1 = data.movies[1].title; alert (title1);}
});
這是我的proxy.php文件。
<?php
// File Name: proxy.php
if (!isset($_GET['url'])) die();
$url = urldecode($_GET['url']);
$url = 'http://' . str_replace('http://', '', $url); // Avoid accessing the file system
echo file_get_contents($url);
我使用代理服務器,因爲我試圖連接的服務器沒有jsonp。
這是我調用API,並且json http://api.rottentomatoes.com/api/public/v1.0/lists/movies/upcoming.json?page_limit=16&page=1&country=us&apikey=k4uaze4937mw3hf82upstxqw
顯示JSON數據 – Ventura
嗨,我添加了api和json。 – tcui222