I work with some government data published through Socrates SODA api .
This API provides a way to retrieve strings through a REST call. The API allows you to limit the query parameterization - basically you can perform a full text search and nothing more. I cannot find a way to form the returned data - for example, only return certain columns of data.
As a result, basically I can get only all rows and all columns of each type of data. This is fine, I think, but I would like to cache it - memoize to use the underscore term.
Is there a template for memoizing ajax calls with jQuery?
EDIT . To give you an idea of ββwhat I'm talking about, this is what I am currently doing.
function onclick(event) { var $t = $(event.currentTarget); var itemId = $t.attr('data-itemid'); var url = getRestUrl(itemId); if (typeof datacache[itemId] === "undefined") { $.ajax({ url : url, cache : true, type : "GET", dataType : "json", error : function(xhr,status,error) { raiseError(error); }, success : function(response, arg2, xhr) { datacache[itemId] = response; doSomethingWithTheData(url, itemId); }}); } else { doSomethingWithTheData(url, itemId); } }
It seems to be faster, although I did not measure it. I really want to know if there is a common template that does something like this that I can use so that everyone who reads the code will immediately see what I'm doing?
source share