Skip to content

Instantly share code, notes, and snippets.

@valdero
Created December 2, 2015 10:22
Show Gist options
  • Save valdero/70a7137609da3e51a1d7 to your computer and use it in GitHub Desktop.
Save valdero/70a7137609da3e51a1d7 to your computer and use it in GitHub Desktop.
/*
Storing Ajax response in array for reuse
*/
var ajaxResults = [];
function exampleAjaxCall() {
$('body').on('click', '.loader', function (e) {
var id = $(this).attr('pid');
var data = {
pid: id
};
$.ajax({
url: '/Store/Details',
type: 'GET',
dataType: 'html',
data: data,
cache: false,
success: function (data) {
$('.panel').html(data);
ajaxResults.push(data);
}
});
});
}
function getPrevious() {
$('body').on('click', '.get-back', function (e) {
$('.panel').html(ajaxResults.pop());
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment