Storing Json As Variable For Reuse Within Another Function
I am learning jQuery and I would like to find out how to re-use ajax json data without having to make a second request. e.g. Categories Select Box:
Solution 1:
You can associate arbitrary data with a DOM element with .data()
. Use the following to store it, after fetching the JSON:
jQuery("#products").data('productData', myData);
Then retrieve it with this:
var myData = jQuery("#products").data('productData');
Post a Comment for "Storing Json As Variable For Reuse Within Another Function"