javascript - Filtering array of JSON data using multiple controls -
I used bootstrap and jquery to create a small mobile app that pulls an array of objects from the URL And one of them tables now I have around 5 controls (button groups and dropdowns) that I want to use to filter JSON data. My question is that should I use AJAX? When any control changes, I have a filter without refreshing any page. It has been for many years when I used Ajax (back when I developed into .NET) but I know that it has been built in jquery. This is my jazzery function that makes my table object:
$ (document) .ready (function () {var url = "http: //json.url/"; $ .getJSON (Url, function (json) {var tr; for (var i = 0; i & lt; json.length; i ++) {// Each table row tr = $ ('& lt; tr data-id =' '+ Json [I]. + "Class =" tap "& gt;'); tr.append (" & lt; td> "+" & lt; span & gt; "+ json [i]. Part_number + "& lt; / span & gt;" + "& lt; br>" + json [i] .imer + '\ "& raquo;' + jsan [i] .phases + '& amp; ; Raquo; '+ jsan [ii] voltage +' & amp; raquo; '+ json [i] .rpm); tr.append ("& lt; / td> ); $ ('Table'). Attachment (tr);}}};});
Whether to keep the original array and store it Would it be better to do that? Or every time I click on a filter then let me call it? I have 4 bootstrap button groups and 3 cylike tee inputs that I want to use to filter when changing any or all of them Go (Without Priority Submit Button) I'm just reading on jquery.ajax but I wanted to ask a question because I'm sure I would need some help.
How can AJAX help you? Does JSON url allow you to provide parameters and will filter the data for you?
If you are requesting the URL getJSON
, then do not filter the data for you, I think you have to store the data in the array in javascript, and you were provided Depending on the value of the options, the filter must be filtered on that array
Comments
Post a Comment