ajax jquery不会对ie工作

大家好。 我使用的js / ajax脚本不适用于Internet Explorer。 Firefox还可以。

顺便说一下头标记,即时使用:

$(document).ready(function () { //Check if url hash value exists (for bookmark) $.history.init(pageload); //highlight the selected link $('a[href=' + document.location.hash + ']').addClass('selected'); //Seearch for link with REL set to ajax $('a[rel=ajax]').click(function () { //grab the full url var hash = this.href; //remove the # value hash = hash.replace(/^.*#/, ''); //for back button $.history.load(hash); //clear the selected class and add the class class to the selected link $('a[rel=ajax]').removeClass('selected'); $(this).addClass('selected'); //hide the content and show the progress bar $('#content').hide(); $('#loading').show(); //run the ajax getPage(); //cancel the anchor tag behaviour return false; }); }); function pageload(hash) { //if hash value exists, run the ajax if (hash) getPage(); } function getPage() { //generate the parameter for the php script var data = 'page=' + encodeURIComponent(document.location.hash); $.ajax({ url: "http://pathfofolder/js/loader.php", type: "GET", data: data, cache: false, success: function (html) { //hide the progress bar $('#loading').hide(); //add the content retrieved from ajax and put it in the #content div $('#content').html(html); //display the body with fadeIn transition $('#content').fadeIn('slow'); } }); } 

loader.php包含获取页面的php代码,例如:

 switch($_GET['page']) { case '#link1' : $page = 'contenthere'; break; } echo $page; 

因此,在链接上,我使用链接1将内容加载到div内容中。

该脚本适用于Firefox,但使用Internet Explorer它不会加载内容。 有人可以帮我解决这个问题吗?

它根本没有进入IE的成功function,我也没有从IE获得HTML错误。

最好的祝福。

确保你的HTML是声音。 FF倾向于自动修复语法。