0
在向站點發送請求時(我需要解析某個站點的某些部分,由ajax-request生成,因此我嘗試發送ajax請求)有一些問題。網站redirests我,所以這種方法並不作品:無法設置Ajax重新訪問網站
$.get('http://www.188bet.com/en-gb/Service/LeftIndicator?GetLiveEventDetails&_=1326817486177&IsFirstLoad=true',function (data){alert(data);});
該請求不能被髮送,因爲這個網站重定向。所以有人告訴我,我需要發送頭X-Requested-With:XMLHttpRequest。所以我這樣做:
$.ajaxSetup({
headers: {"X-Requested-With":"XMLHttpRequest"}
});
$.ajax({
type: 'GET',
url: 'http://www.188bet.com/en-gb/Service/LeftIndicator?GetLiveEventDetails&_=1326817486177&IsFirstLoad=true',
success: function(data) {
alert(data);
}
});
但結果是一樣的,請求不發送,哪裏是問題? 網站http://www.188bet.com/en-gb/sports,我講左菜單(我需要解析它)。
yeap,響應是在JSON中。如何做正確的要求? – 2012-01-17 20:42:32
http://api.jquery.com/jQuery.getJSON/ – 2012-01-17 20:45:41