作者:Andou1983 | 来源:互联网 | 2023-09-09 12:54
篇首语:本文由编程笔记#小编为大家整理,主要介绍了Javascript AJAX页面加载相关的知识,希望对你有一定的参考价值。
// AJAXin links
// Stop default actions on the links we want to hijack
$('#navigation a[href$=html]').bind('click', function(event) {
event.preventDefault()
});
// Click on link within id with ending of HTML triggers this
$('#navigation a[href$=html]').click(function(e) {
// Grab the href attribute of the clicked A and use it as linkURL variable
var linkURL = $(this).attr('href');
// Show the Element that the content will be displayed in
$('#ajaxContainer').show();
// AJAX
$.ajax({
// Use the variable linkURL as source for AJAX request
url: linkURL,
dataType: 'html',
// If all goes well
success: function(data) {
// This is where the fetched content will go
$('#ajaxContainer')
// HTML added to DIV while content loads (It loads my spinner, you'll have to come up with your own)
.html(' ')
// Load from this URL this element class
.load(linkURL + ' .columnWide');
// It worked mother flipper
$.print('Load was performed.');
}
});
});