1
嗨,大家第一次發佈和總Ajax noob。阿賈克斯GET失敗難
只是想知道如果任何人都可以指出,我已經走了可怕的錯誤,感謝所有幫助我能
// jQuery來處理Ajax加載鏈接
//Function to handle back and forward
var pooped = ('state' in window.history && window.history.state !== null),
initialURL = location.href;
//function to handle the scenarios where back and forward buttons used in browser
$(window).bind("popstate", function (e) {
// Ignore inital popstate that some browsers fire on page load
var initialPoop = !pooped && location.href == initialURL;
pooped = true;
if (initialPoop) {
return;
}
ajaxLinkPage(location.href);
});
// Ajax Link function
var ajaxLinkPage = function (linkurl) {
console.log(linkurl);
$.ajax({
type: 'GET',
url: linkurl,
data: {},
complete: function (data) {
$('#body_wrap').html($("#body_wrap", data.responseText).html());
history.pushState({
page: linkurl
}, linkurl, linkurl);
}
});
};
// Below this is the Ajax Trigger
$("#nav ul li a").click(function(){
var linkurl = $("#nav ul li a").attr("href");
ajaxLinkPage(linkurl);
$('#dvLoading').css('display','block');
});
阿賈克斯調用不起作用,如果我把.click event.preventDefault()
在一些頁面上工作在鉻,但在safari中根本不工作。
謝謝!
initialPoop ... :) – smerny 2014-10-03 19:23:55
IM筋疲力盡只是閱讀本 – danronmoon 2014-10-03 19:24:09
只需添加return false;到您的點擊事件。 – Tyr 2014-10-03 19:24:18