我試圖根據用戶興趣創建一個簡單的Newsfeed頁面。 下面我已經提供了我的代碼相同..我只是不明白這裏的問題..事情是這樣的代碼工作正常在我的本地主機,但它不工作在同一個在線servers.But $(窗口).scroll(函數()的正常使用和的數據都是被抓取正常但是.load()函數是無法獲取DATAS。Javascript .load()函數未執行
我是gettingbelow錯誤在JavaScript Consol.log
XMLHttpRequest無法加載 http://redirect.main-hosting.com/error404.php/26?domain=www.nizilla.tk。 否請求的 資源上存在'Access-Control-Allow-Origin'標頭Origin'http://www.nizilla.tk'因此不允許 訪問。
我也嘗試更改src路徑爲src =「./profile-newsfeed/jquery-1.9.1.min.js」,但仍面臨同樣的錯誤。
/*-------------------------------- */
<script src="http://www.nizilla.tk/profile-newsfeed/jquery-1.9.1.min.js"> </script>
<script type="text/javascript">
$(document).ready(function() {
var track_load = 0; //total loaded record group(s)
var loading = false; //to prevents multipal ajax loads
var total_groups = <?php echo $totalpage; ?>; //total record group(s)
//alert(total_groups);
if(total_groups<=0)
{
window.location='http://www.nizilla.tk/profile php/profilefollow.php';//
}
else
{
$('#container').load('http://www.nizilla.tk/profile php/userinterest.php', {'group_no':track_load}, function() {track_load++;}); //load first group
$(window).scroll(function() { //detect page scroll
if($(window).scrollTop() + $(window).height() == $(document).height()) //user scrolled to bottom of the page?
{
if(track_load <= total_groups && loading==false) //there's more data to load
{
loading = true; //prevent further ajax loading
$('.animation_image').show(); //show loading image
//load data from the server using a HTTP POST request
//http://www.nizilla.tk/profile php/userinterest.php
$.post('http://www.nizilla.tk/profile php/userinterest.php',{'group_no': track_load}, function(data){
$("#container").append(data); //append received data into the element
//hide loading image
$('.animation_image').hide(); //hide loading image once data is received
track_load++; //loaded group increment
loading = false;
}).fail(function(xhr, ajaxOptions, thrownError) { //any errors?
alert(thrownError); //alert with HTTP error
$('.animation_image').hide(); //hide loading image
loading = false;
});
}
}
});
}
});
這將是很有益的,如果你能指出我的錯誤here..i真的很感謝你的幫助
結賬此相關的帖子。 http://stackoverflow.com/questions/6114436/access-control-allow-origin-error-sending-a-jquery-post-to-google-apis – Jason