Jump to content

Digger

Members
  • Posts

    13
  • Joined

  • Last visited

Digger's Achievements

Member

Member (2/5)

0

Reputation

3

Community Answers

  1. The reason for my initial question is after submit and confirmation toast was fired the a div with dynamic contents is reloaded but on the page it was quickSubmit(formData,'/SubmitUrl'php','toastr'); $('#div').load('new-results-after-change.php'); But the results are hit and miss, sometimes i need to refresh the whole page before the results will show so was looking for something like if(quickSubmit(blady,bla)==='success') { $('div').load('newresult'); } What i have done is function quickSubmit(form_data, sUrl, successCB, reloadTable1, reloadTable2){ $.ajax({ url: sUrl, method: "POST", data: form_data, contentType: false, cache: false, processData: false, success: function(data){ var result = JSON.parse(data); successCB(result); if(reloadTable1!=='') { reloadTable1 } if(reloadTable2!=='') { reloadTable2 } }, error: function(XMLHttpRequest, textStatus, errorThrown){ } }); } I'm not sure how it will effect the other pages i call the function from but only time will tell Thanks for you help
  2. i dont want to call a php function i was to get the results from the javascript function java.js function quickSubmit(form_data, sUrl) { var retVal = null; $.ajax({ url: sUrl, method: "POST", data: form_data, contentType: false, cache: false, processData: false, success: function(data) { var result = JSON.parse(data); retVal = result; return false; }, error: function(XMLHttpRequest, textStatus, errorThrown) { var result = errorThrown; retVal = result; return false; } }); return retVal; } something.html var result = quickSubmit(formData, '/addresstosubmitto/page.php'); alert(result) I just want to know if this is possible
  3. I have a .js file with the following code in function quickUpdate(form_data, sUrl, rUrl) { $.ajax({ url: sUrl, method: "POST", data: form_data, contentType: false, cache: false, processData: false, success: function(data) { result = JSON.parse(data) Swal.fire({title: result.title, text: result.text, icon: result.icon}); }, error: function(XMLHttpRequest, textStatus, errorThrown) { alert(errorThrown); } }); } Everything seems to work fine but i am trying to get the results on the call page, in php it would be something like public function quickUpdate($foo, $foo) { // do something return bar; } but when i try var retVal = null; $.ajax({ url: sUrl, method: "POST", data: form_data, contentType: false, cache: false, processData: false, success: function(data) { var result = JSON.parse(data); retVal = result; return false; }, error: function(XMLHttpRequest, textStatus, errorThrown) { var result = errorThrown; retVal = result; return false; } }); return retVal; and call it from a page var result quickUpdate(formData, '/admin/client/process/emailpreferences'); alert(result.title); or alert(result); the alert is says Null or Undefined Is their a way of doing this or am i just wasting my time thanks
  4. 0 I am trying to pass array results from a php submission form back to jquery i can trigger a success or fail message using toast. i am using $ret["icon"] = "success"; $ret["title"] = "Request Deleted Successfully"; echo json_encode($ret); this is the result {"icon":"success","title":"Request Deleted Successfully"} but to trigget the toast object i need Toast.fire({icon: 'success',title: 'Request Deleted Successfully.'}) Looking at the different i only need to remove the commas from the array key but i dont know how to do this in jquery or javascript Can anyone please help
  5. Thank you so much, i think it was a case of me going code blind, i cant believe i didn't think about that. I've modified your suggestion a bit, i've put it in a javascript file and included it var Toast = Swal.mixin({ toast: true, position: 'top-end', showConfirmButton: false, timer: 5000 }); function loadDataTable(div,urlLink){ $(div).html("<div id='loader'><center><i class='fas fa-spinner fa-3x fa-spin -auto m-5'></i></center></div>"); $("#requests-container").load(urlLink, function(){ $("#project-requests").DataTable({ "order": [[0, "desc"]], "responsive": true, "lengthChange": true, "autoWidth": false, "pageLength": 25, "aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]], "buttons": ["copy", "pdf", "print", "colvis"] }).buttons().container().appendTo("#project-requests_wrapper .col-md-6:eq(0)"); }); } So now the call is loadDataTable("#requests-container","'.DIR.'admin/dashboard/requests"); Basically this so so i can trigger it from anywhere and for anything on the site Thanks again for your help
  6. I have a DataTables table and I have managed to get everything working fine. Within each row i have an action button with either accepts, approves or deletes the row. Like i say everything is working but after the respective button has been clicked I have to load the entire page again to get the table to refresh and it just doesnt look right. Anyway her is the code initial code to load the results into the table $(document).ready(function(){ $("#requests-container").html("<div class=\'col-sm-12 py-5\'><center><i class=\'fas fa-spinner fa-3x fa-spin mb-3 text-muted\'></i><br /></center></div>"); $("#requests-container").load("'.DIR.'admin/dashboard/requests", function(){ $("#project-requests").DataTable({ "order": [[0, "desc"]], "responsive": true, "lengthChange": true, "autoWidth": false, "pageLength": 25, "aLengthMenu": [ [10, 25, 50, -1], [10, 25, 50, "All"] ], "buttons": ["copy","pdf", "print", "colvis"] }).buttons().container().appendTo(\'#project-requests_wrapper .col-md-6:eq(0)\'); $("#project-requests_wrapper").children(":first").addClass("p-2"); $("#project-requests_wrapper").children(":first").next().next().addClass("p-2"); }); }); Then I have this once the link has been clicked $(document).on("click", ".action-requests", function(e){ e.preventDefault(); var Toast = Swal.mixin({ toast: true, position: \'top-end\', showConfirmButton: false, timer: 5000 }); var pageLink = $(this).attr("href"); var requestId = $(this).attr("data-id"); $.post("admin/dashboard/queries/" + pageLink, { id: requestId }, function(data, status){ if(status === "success") { if(pageLink == "approverequest") { Toast.fire({icon: "success",title: data}); $("#requests-container").html("<div class=\'col-sm-12 py-5\'><center><i class=\'fas fa-spinner fa-3x fa-spin mb-3 text-muted\'></i><br /></center></div>"); $("#requests-container").load("'.DIR.'admin/dashboard/requests", function(){ $("#project-requests").DataTable({ "order": [[0, "desc"]], "responsive": true, "lengthChange": true, "autoWidth": false, "pageLength": 25, "aLengthMenu": [ [10, 25, 50, -1], [10, 25, 50, "All"] ], "buttons": ["copy","pdf", "print", "colvis"] }).buttons().container().appendTo(\'#project-requests_wrapper .col-md-6:eq(0)\'); $("#project-requests_wrapper").children(":first").addClass("p-2"); $("#project-requests_wrapper").children(":first").next().next().addClass("p-2"); }); } else { Toast.fire({icon: "success",title: data}); $("#requests-container").html("<div class=\'col-sm-12 py-5\'><center><i class=\'fas fa-spinner fa-3x fa-spin mb-3 text-muted\'></i><br /></center></div>"); $("#requests-container").load("'.DIR.'admin/dashboard/requests", function(){ $("#project-requests").DataTable({ "order": [[0, "desc"]], "responsive": true, "lengthChange": true, "autoWidth": false, "pageLength": 25, "aLengthMenu": [ [10, 25, 50, -1], [10, 25, 50, "All"] ], "buttons": ["copy","pdf", "print", "colvis"] }).buttons().container().appendTo(\'#project-requests_wrapper .col-md-6:eq(0)\'); $("#project-requests_wrapper").children(":first").addClass("p-2"); $("#project-requests_wrapper").children(":first").next().next().addClass("p-2"); }); } } }); }); Like i said its a bit long winded for such a simple action but if its not like this DataTables wont load after the submission I was just wondering if anyone has a simpler idea to shorten the coding Thanks
  7. $(document).ready(function(){ $( "#nav-home").load("'.DIR.'admin/client/list", function() { $(".dropdown-item").on("click", function(){ alert("clicked"); }); }); }); That worked
  8. Yes i tried it before I posted the question
  9. The code entered isn't the exact code it was just a quick example everything is done proper <script> $(document).ready(function){ $( "#nav-home").load("'.DIR.'admin/client/list" ); /* $('.dropdown-item').click(function(){ alert('clicked'); }); Doesnt work */ /* $('.dropdown-item').on('click', function(){ alert('clicked'); }); Doesnt work */ /* $('.dropdown').on('click', 'a', function(){ alert('clicked'); }); Doesnt work */ /* $('.dropdown-item').live('click', function(){ alert('clicked'); }); Doesnt work */ /* $('.dropdown-item').live('click', 'a', function(){ alert('clicked'); }); Doesnt work */ /* $('.dropdown-item').bind('click', function(){ alert('clicked'); }); Doesnt work */ /* $('.dropdown-item').bind('click', 'a', function(){ alert('clicked'); }); Doesnt work */ }; </script> None of the above are working
  10. I have a page loaded into a div <script> $(document).ready(function(){ $( "#nav-home" ).load("'.DIR.'admin/client/list" ); }); </script> `That work fine Within admin/client/list is the following <div class="dropdown btn-group"> <button class="btn btn-secondary btn-sm dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Action</button> <div class="dropdown-menu dropdown-menu-right" role="menu" aria-labelledby="dropdownMenuButton" style="right:auto; left: auto;"> <a class="dropdown-item" href="#reject"><i class="fas fa-angle-right mr-2"></i> Reject / Cancel</a> <a class="dropdown-item" href="#approve"><i class="fas fa-angle-right mr-2"></i> Approve</a> <a class="dropdown-item" href="#active"><i class="fas fa-angle-right mr-2"></i> Activate</a> <a class="dropdown-item" href="#delete"><i class="fas fa-angle-right mr-2"></i> Delete</a> </div> </div> I cannot get the links to trigger with Jquery I have tried <script> $('.dropdown-item').click(function $('.dropdown-item').on('click', function $('.dropdown-item').on('click','a', function $('.dropdown-item').live('click', function $('.dropdown-item').live('click', 'a' function $('.dropdown-item').bind('click', function $('.dropdown-item').bind('click', 'a' function Nothing seems to be working so any help would be much appreciated
  11. Ive tried $instance = new self("$type:host=$host;dbname=$name;default-character-set=utf8mb4", $user, $pass); and $instance = new self("$type:host=$host;dbname=$name;charset=utf8mb4", $user, $pass); but still getting the same error
  12. My web host has upgraded the server to PHP8.1 and MySql8 2 days ago and i am constantly getting this error PDO::__construct(): Server sent charset (255) unknown to the client. Please, report to the developers in /home/***/***/app/Helpers/Database.php on line 63 This was line 63 $instance = new self("$type:host=$host;dbname=$name;charset=utf8", $user, $pass); and this is what i was advised to change it $instance = new self("$type:host=$host;dbname=$name;default-character-set=utf8", $user, $pass); Sadly the error still persists Here in the class function its in public static function get($group = false) { // Determining if exists or it's not empty, then use default group defined in config $group = !$group ? [ 'type' => DB_TYPE, 'host' => DB_HOST, 'name' => DB_NAME, 'user' => DB_USER, 'pass' => DB_PASS, ] : $group; // Group information $type = $group['type']; $host = $group['host']; $name = $group['name']; $user = $group['user']; $pass = $group['pass']; // ID for database based on the group information $id = "$type.$host.$name.$user.$pass"; // Checking if the same if (isset(self::$instances[$id])) { return self::$instances[$id]; } try { // I've run into problem where // SET NAMES "UTF8" not working on some hostings. // Specifiying charset in DSN fixes the charset problem perfectly! $instance = new self("$type:host=$host;dbname=$name;charset=utf8", $user, $pass); $instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Setting Database into $instances to avoid duplication self::$instances[$id] = $instance; return $instance; } catch (PDOException $e) { //in the event of an error record the error to ErrorLog.html Logger::newMessage($e); Logger::customErrorMsg(); } } Its worked fine for the past 8 years until 2 days ago but i am now pulling mu hair out Any help or advice would be greatly appreciated
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.