The following warnings occurred: | ||||||||||||
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
|
Update Database from Javascript Function - Printable Version +- UserSpice (https://userspice.com/forums) +-- Forum: Support Center (https://userspice.com/forums/forumdisplay.php?fid=23) +--- Forum: UserSpice 4.3 and Below (https://userspice.com/forums/forumdisplay.php?fid=26) +--- Thread: Update Database from Javascript Function (/showthread.php?tid=946) |
Update Database from Javascript Function - ptrh - 02-12-2018 Hello! Thank you UserSpice team for all the hard work you put in, people like myself are much appreciative! Question: is it possible to call database functions (ex. $db->update) from Javascript? Does this involve AJAX requests? I'm new to the world of PHP so I could use some direction. The content I am including with UserSpice's user management runs via JS. There are points where I'd like certain JS functions to call $db functions. Cheers, Patrick Update Database from Javascript Function - mudmin - 02-12-2018 There are a lot of ways to do it, but essentially what I do is write a jquery function at the bottom of my page that makes an ajax call. I create a "parser" php file where it does all the db work. Here is a basic explanation of one of my jq ajax calls and the parser file. https://pastebin.com/qtQEpWuZ Update Database from Javascript Function - mudmin - 02-12-2018 There are a lot of ways to do it, but essentially what I do is write a jquery function at the bottom of my page that makes an ajax call. I create a "parser" php file where it does all the db work. Here is a basic explanation of one of my jq ajax calls and the parser file. https://pastebin.com/qtQEpWuZ Update Database from Javascript Function - ptrh - 02-12-2018 Thanks for the quick reply! I'll take a look at this. Update Database from Javascript Function - ptrh - 03-01-2018 Hi Mudmin, This worked like a charm! Thank you kindly. Do you have any resources/posts to look at for setting up self permission checkboxes on the registration page? For instance, the user goes to register and sees this form: First Name [] Last Name [] Email [] Choose a Password [] *Select all that apply: Manager [] Traveler [] ... [] ... [] [REGISTER] I took a look around the forum but had trouble finding a relevant post. Patrick Update Database from Javascript Function - mudmin - 03-01-2018 Hmm. You can add them in usersc/scripts/additional_join_form_fields.php They would be just normal checkboxes. I'm about to run out but if that doesn't make sense, let me know and I can help with some code. Update Database from Javascript Function - ptrh - 03-06-2018 Again thanks for the direction, was able to figure out the code. |