我想從僅使用javascript和ajax的網頁獲取數據。我的網頁正在返回一個數組,我想在我的html頁面上顯示。我不能用這個PHP。我如何從使用AJAX的網頁獲取數據?
這是我正在使用的代碼。
<html>
<head>
<title>Getting Started Extension's Popup</title>
<script src="background.js">
</script>
<script type="text/javascript">
$.ajax({
url:"http://www.mydomain.com/page1.php?url='http://open.live.bbc.co.uk/weather/feeds/en/2643743/3dayforecast.rss'",
type: 'GET',
dataType: 'jsonp'
});
function callback(data){
$('#iec_azn_data').html(data.results[0]);
}
</script>
</head>
<body>
Hi
<div id="iec_azn_data">
</div>
</body>
</html>
在ajax請求中使用成功。成功:功能(數據){//你的代碼} – Dineshkani