Show Alert after execute of a php script ?


Topic: Show Alert after execute of a php script ?

creativewebconcept asked 4 years ago

Expected behavior I want my alert to show when my php code as been execute (in the IF statement)

Actual behavior It's not working ... I can only show the alert by clicking with a button...

Resources (screenshots, code snippets etc.)

HERE IS WHAT I TRIED TO MAKE BUT IT IS NOT WORKING .... :(

Item have been removed from your cart
    <?php
    if (isset($_GET['action'])) {
      if ($_GET['action'] == 'delete') {
        foreach ($_SESSION['cart'] as $key => $value){
          if ($value['item_id'] == $_GET['id']) {
            unset($_SESSION['cart'][$key]);
            echo "<script>
            triggersBasic.forEach(function (trigger, index) {
            let instance = mdb.Alert.getInstance(document.getElementById(instancesBasic[index]));
            document.getElementById(trigger).addEventListener('click', function () {
              instance.show();
            });
            });
            </script>";
            echo "<script>$('.alert').show()</script>";
          }
        }
      }
    }
    ?>

Any help would be really appreciate ..


Grzegorz Bujański staff answered 4 years ago

Do you have any errors in the console? The uploaded code is missing the variables triggersBasic andinstancesBasic. Does this function have access to these variables?


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: MDB Standard
  • MDB Version: 2.0.0
  • Device: PC
  • Browser: Chrome
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No