this is how I would do it! <script type="text/javascript"> jQuery.ajat=function(url){ var results = [] jQuery.ajax({ async:false, url:url, dataType: "text", complete:function(res) { var data = res.responseText; var a = data.split(/\n/) var headings = a[0].split(/\t/) for (var i = 1; i < a.length; i++){ var line = a[i].split(/\t/) var obj = {} for (var j = 0; j < line.length; j++){ obj[headings[j]] = line[j] } results.push(obj) } } }) return results } $(function(){ var x = $.ajat('data.txt') $.log(x) }); </script>
http://cigar.dynalias.org/demo/ajat/ajat.html On 3/8/07, Ⓙⓐⓚⓔ <[EMAIL PROTECTED]> wrote: > it's similar to Json, but no field names that get repeated for each record. > > you do an ajax request , get the response and split it with "\n", now > you have an array of records, then you split each record with "\t" and > you've got a 2 dimensional array.. all the data in perhaps half the > size. > > if you really want it as an array of objects you need a header record, > which gets split with "/t" then loop thru it assigning the array > elements to an object field. > > Does this sound like what you would need for extra light weight > transport? I could draft a plugin, it's not rocket surgery! > > > On 3/8/07, Daemach <[EMAIL PROTECTED]> wrote: > > > > Jake, you are famous for this ;) > > > > Sounds great in theory but an example of how to accomplish this and the > > reasoning behind that claim would be very helpful! > > > > I meant lightweight in terms of querying more than page size, by the way. I > > should have been more clear. > > > > > > > > Ⓙⓐⓚⓔ wrote: > > > > > > if you're pushing the limit for 'light weight', consider simple tab > > > delimited data! a simple header and you can convert it to Javascript > > > in a few lines of code! Not as easy as an eval, but the speed will be > > > worth it! > > > > > > On 3/8/07, Daemach <[EMAIL PROTECTED]> wrote: > > >> > > >> While discussing json support in Cold Fusion with Rey Bango, I had a > > >> small > > >> flash of insight. It's a pretty easy matter to take a recordset or any > > >> other structure, serialize it to JSON format and output that string > > >> inside > > >> of an eval() directly in the HTML itself. With jQuery and the ready() > > >> function when the page loads you could have a client-side dataset ready > > >> to > > >> go. Why make ajax calls when you can query a client-side datasource for > > >> things like an auto-complete list? > > >> > > >> So the questions are: > > >> > > >> -- What are the limits the browser can handle in terms of record count > > >> and > > >> still retain a lightweight feel? (depends on RAM, processor speed - I > > >> know, > > >> but generally...) > > >> -- What would the optimal structure look like for searching given a > > >> function > > >> like an auto-complete form field? > > >> -- Is a "for in" loop the best way to query or is there something more > > >> efficient? > > >> -- What benefits, if any, would this have for filtering/sorting a table? > > >> > > >> Or is this a bad idea to start with? Obviously ajax still has its place, > > >> but it seems like this concept might work for some things... > > >> -- > > >> View this message in context: > > >> http://www.nabble.com/Querying-javascript-datasources---what-factors-improve-speed-efficiency--tf3373312.html#a9387190 > > >> Sent from the JQuery mailing list archive at Nabble.com. > > >> > > >> > > >> _______________________________________________ > > >> jQuery mailing list > > >> discuss@jquery.com > > >> http://jquery.com/discuss/ > > >> > > > > > > > > > -- > > > Ⓙⓐⓚⓔ - יעקב ʝǡǩȩ ᎫᎪᏦᎬ > > > _______________________________________________ > > > jQuery mailing list > > > discuss@jquery.com > > > http://jquery.com/discuss/ > > > > > > > > > > -- > > View this message in context: > > http://www.nabble.com/Querying-javascript-datasources---what-factors-improve-speed-efficiency--tf3373312.html#a9387322 > > Sent from the JQuery mailing list archive at Nabble.com. > > > > > > _______________________________________________ > > jQuery mailing list > > discuss@jquery.com > > http://jquery.com/discuss/ > > > > > -- > Ⓙⓐⓚⓔ - יעקב ʝǡǩȩ ᎫᎪᏦᎬ > -- Ⓙⓐⓚⓔ - יעקב ʝǡǩȩ ᎫᎪᏦᎬ _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/