How do you use jQuery .data() to store html?
- by Al
Hi all - when I look up the syntax for .data(), it gives examples like this:
$('body').data('foo', 52);
I am doing AJAX loads and I was wondering if it is possible to store the incoming html using .data() so once the content is loaded, I would not need to do another AJAX load if the same link is clicked again - I would check to see if the .data key is empty.
Would something like this work?:
To load the contents of a #ajaxdiv into storage:
$('body').data('storage', div#ajaxdiv.html());
To test if the data has already been loaded:
if $('body').data('storage') != '' {
div#ajaxdiv.html($('body').data('storage'));
}
Thanks in advance!!
Al