I am a classic ASP programmer and I have for some time now mixed the good old safe classic ASP with JQUERY with good results really. But I now have a project that requires more offline data processing than ever before. I'm learning as I go and this is my latest stumble...:
I need to take an array created server-side and populate it client-side ( and offline) in an html table which is powered by a jquery livesearch. Now I need to store the array (classic ASP) either in a cookie or local storage. Then be able to read it into an html table.
Here's how I would do it with classic ASP if I could rely on server-side connection:
<tbody>
<%
For a = 0 to Pris_ant
%>
<tr>
<td><%=Priser(a,0)%></td>
<td><%=Priser(a,1)%></td>
<td><%=Priser(a,2)%></td>
<td width="67"><%=Priser(a,3)%>,-</td>
<td width="67"><%=Priser(a,4)%></td>
<td width="70"><%=Priser(a,5)%></td>
</tr>
<% Next %>
</tbody>
OK, not the smoothest code but it works as long as I'm on a hard-line or in an area with good LTE connection. But the users are rarely on sites with good mobile data connection and I need to be able to generate this list from a local storage even IF there's no network. A.k.a I can open a locally stored HTML page and read the data from the local storage.
So the BIG question is how do I do this in the simplest manner possible ? I've searched high and low and i'm none the wiser. So any help would be greatly appreciated.
UPDATE:
ok so some background information. I am downloading this data with GetJson. And when I try the $each function on the "raw data" - it works like a charm.
However: In order to save the data in a localstorage I use JSON.stringify first. When I retrieve the data from the localstorage, I try using JSON.parse - but then all I get is: "JSON.parse is not a function"
Here's the data as it shows up after fetching it from localstorage:
Var JsonData = [{"rowNumber":563663,"hasWarning":true,"isInvoiceAccount":true,"phone":"","name":"Bertel AS","address1":"Co/Skanning","address2":"PB 52","attention":"","mobile":"","email":"faktura@bos","fax":"","zipCity":"N-1471 Lørenskog","invoiceAccount":"","account":"3","country":"NORGE","salesRep":"4","countryCode":"no"},{"rowNumber":563674,"hasWarning":false,"isInvoiceAccount":true,"phone":"","name":"LILLEHAMMER","address1":"POSTBOKS 1100","address2":"","attention":"","mobile":"","email":"","fax":"","zipCity":"N-2605 LILLEHAMMER","invoiceAccount":"","account":"14","country":"NORGE","salesRep":"4","countryCode":"no"},{"rowNumber":563676,"hasWarning":true,"isInvoiceAccount":true,"phone":"63929788","name":"Nygaard","address1":"Postboks 82","address2":"","attention":"","mobile":"","email":"karosseri","fax":"","zipCity":"N-2051 Jessheim","invoiceAccount":"","account":"16","country":"NORGE","salesRep":"4","countryCode":"no"},{"rowNumber":563686,"hasWarning":false,"isInvoiceAccount":true,"phone":"","name":"TRØGSTAD","address1":"POSTBOKS 165","address2":"","attention":"","mobile":"","email":"tkarosse","fax":"","zipCity":"N-1860 TRØGSTAD","invoiceAccount":"","account":"26","country":"NORGE","salesRep":"4","countryCode":"no"}]
When I try to use $.each I either get "undefined" OR I get a split for each letter in the variable string.
$.each( JsonData, function ( index, value ) {
console.log( "index: " + index + ", name: " + value.name );
});
I have also tried this:
$.each( JsonData, function ( index, value ) {
console.log( "index: " + index + ", name: " + value[index].name );
});
I have tried to use JSON.Stringify and JSON.PARSE, but nothing has helped me thus far.
// var JsonData = JSON.stringify(this.result);
// var JsonData = $.parseJSON(JSON.stringify(this.result));
// var JsonData = this.result;
// var JsonData = JSON.parse(JsonData);