在自己頁面顯示其他網站上面的數據,需要用Ajax,就涉及到跨域問題, 
解決方案:jQuery.support.cors = true; (瀏覽器支持跨域訪問), 
實例: 
復制代碼 代碼如下:
 
//瀏覽器支持跨域訪問 
jQuery.support.cors = true; 
$.ajax({ 
url: "http://www.rj99999.com/Price/ListPrice.html", 
dataType: 'html', 
success: function (data, textStatus) { 
//nowPrice為本頁面顯示數據控件,#price', data為從其他網站取出名為price的元素。 
$("#nowPrice").text(jQuery('#price', data).html() + "元/克"); 
}, 
error: function (xhr, ajaxOptions, thrownError) { 
$("#nowPrice").text("暫時無法顯示"); 
} 
}); 
//實時刷新 
//每60000毫秒/1分鐘調用togglecountdowntime()方法。 
setTimeout("togglecountdowntime()", 60000); 
新聞熱點
疑難解答
圖片精選