[英]Trying to make ajax calls on my site. Works on modern browsers (IE9, Chrome, FF) but IE8
我正在嘗試用ajax調用該內容的網站,主要是因為該網站有一個廣播電台,我希望我站點的用戶不要停止收聽廣播,因為他們正在閱讀其他文章或類似內容。
我正在使用Jquery。
所以...我有這個功能:
$(function(){
// Get a reference to the content div (into which we will load content).
var jContent = $( "#content" );
// Hook up link click events to load content.
$( ".enlaceajax" ).live("click", function( objEvent ){
var jLink = $(this) ;
// Clear status list.
$( "#ajax-status" ).empty();
//Obtenemos de donde estan obteniendo el valor del enlace. ya sea que den clic en el combo box o en un enlace normal.
var value = jLink.attr("value");
var href = jLink.attr("href");
alert(href);
if(typeof value === 'undefined')
{
var linkgo = href;
}
else {
var linkgo = value;
}
// Launch AJAX request.
$.ajax(
{
// The link we are accessing.
url: linkgo,
// The type of request.
type: "GET",
// The type of data that is getting returned.
dataType: "html",
success: function( strData ){
// Load the content in to the page.
jContent.html( strData );
$('html, body').animate({ scrollTop: 0 }, 0);
}
}
);
// Prevent default click.
return( false );
}
);
}
);
我通過外部文件將代碼添加到我的網站上。 文件正確加載,jQuery也正確加載。 我在Firefox上使用firebug進行了測試,一切正常,腳本可以正常運行,並且所有內容都已加載到div“內容”上。
但是,由於某種原因,當我在IE8上嘗試此代碼時,它不適用於PHP文件。 當我單擊一個PHP文件(類似於nota.php?nota=12345
)時,div內容就消失了。 但是,如果我單擊html鏈接(如test.html
),則可以正常工作。
我嘗試在幾個地方尋找,但是我沒有找到任何解決方案……而且,我對jquery確實是個菜鳥。
除了“只是消失”以外,您還需要更多有關該錯誤的詳細信息。 嘗試加載IE開發者工具欄。 http://www.microsoft.com/download/en/details.aspx?id=18359
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.