Alert keeps popping up no matter what I do!

Asked

Viewed 68 times

0

I took the code of a shopping cart on the internet. And there is the cart page where the customer can increase or decrease the quantity of the product. The problem with this code is that each time you increase or decrease a quantity it appears an "Updated amount" Alert, I have tried everything already deletes the part of code that has this Alert, already modified in php and so far Alert continues to be displayed. I wanted it to stop being displayed every time you update the amount. I’ll keep the code short, only the parts that matter.

Cart.js

 add : function (id) {
  // add () : add item to cart
  // PARAM id : product ID

cart.ajax({
  url : "4b-ajax-cart.php",
  data : {
    req : "add",
    product_id : id
  },
  load : function (res) {
    cart.count();
    // @TODO
    alert(res);
  }
});
  },
  

cart php.

<!--- Botão para aumentar e diminuir quantidade ---->

 <td><input class="form-control" id='qty_<?= $id ?>' onchange='cart.change(<?= $id ?>);' type='number' value='<?= $qty ?>'/></td>

<!--- Fim botão para aumentar e diminuir quantidade ---->

 /* [Aumentar e diminuir qty] */
  case "change":
if ($_POST['qty'] == 0) {
  unset($_SESSION['cart'][$_POST['product_id']]);
} else {
  $_SESSION['cart'][$_POST['product_id']] = $_POST['qty'];
    die ("Quantidade atualizada");
}
   die ("Produto removido");
break;

  • If you removed that alert, cleared the cache and reloaded the page but it didn’t work, use the IDE to search all "Alert" inside the project folder, maybe there is another one besides this and didn’t notice

1 answer

1


Remove the alert(res); ajax load, I don’t understand why I use the die, return a string, treat its return with the function success ajax.

  • I removed Alert(res) but Alert continues. I have to disable the browser Network, clear cache and cookies?

  • When I remove the die, Alert continues but without any message, only the same dialog box.

  • Somewhere is entering Alert(), it is not displayed if it does not exist in the code. I suggest using an MVC standard, if it’s an external link, you can use the jquery legacy just to handle the return.

  • Interestingly, in the project folder I already delete Alert(res). And when I open the browser IDE, Alert(res) keeps popping up. And if I delete it in the IDE Alert some. The question is why it keeps appearing in the IDE if I have already deleted it in the original folder?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.