Simple ajax request

Hello, i know, there is many post about this, all for different purposes, mainly post about json and infinite loading for blog post or portfolio etc… What i’m looking for is a simple ajax call inside a container, i want to call the template content inside it without reloading header (and menu) and footer. I want to use backbone router to do this.

Thanks to enlighten me…

Hi,
I can’t answer it for Backbone but for jQuery.
For loading a template without header or other stuff ask for ajax: <?php if(!r::ajax()) { //you header snippet call } ?>
Here an example for jquery ajaxload:

var mainnav = $('li.mainnav a');

$.ajaxSetup ({  
	cache: false
});

mainnav.click(function(){
	var ajaxContent = $('.ajaxContent'),
		pageToLoad = $(this).attr('href'),
		ajaxPlaceholder = '<i class="fa fa-refresh fa-spin fa-4x"></i>', 
		pageContent;
	
	console.log(pageToLoad);
							
	$.get(pageToLoad, function(data){
		pageContent = data;
		ajaxContent.html(ajaxPlaceholder).load(pageContent, function() {
			alert('Load was performed.');
		});
	}, 'html');
return false;
});

In this example is .ajaxContent a div in which is loading the content.

Kind regards