jQuery - Transfer Data by ID from PHP to JavaScript + jQuery -
There is a list with many entries (100+) identified by me (MongoDB-) ID Each entry is an HTML - In the table and there is a checkbox in it. When the user now chooses a group, then I have to ask the server that each entry is in a specific group. The query is not heavy to subscribe, but I can not execute it 100 + times, it is a lot of load.
Currently I have php code to get group membership (too long to post) and the following javascript code, which is executed whenever it is selected: < Pre> My problem is this: If I am in the selected group once, I can check once and then every ID. Your question is a bit difficult to understand, but I think you should post a JSON list and Post in a query, and it should handle the ITRT server-side, such as: If this does not answer your question, please More details of the question Resubmit with $ ('checkbox [data-type = "group"]'). Set each (function (idx, val) {// ID and check / uncheck it});
id_list = {}; $ ('Checkbox [data-type = "group"]'). Each (function (idx, val) {the_id = // get an ID in a variable in any way; id_list [the_id] = val;}); $ .jax ($ url: "some url", data type: "jsan", type: "post", data: id_list}). (Function (data) {// Using the returned data, each check / uncheck / / assuming that the returned data was the format of the ID: boolean, and boolean determines that it should be checked (such as {1: True, 2: wrong, 3: wrong}) .each (data, function (index, value) {If (value == true) {$ ('checkbox #' + index) .attr ('checked', true); } Else {$ ('checkbox #' + index) .attr ('checked', false);}});
Comments
Post a Comment