php - ajax call to set/update session shopping cart does not fire -


i've used stackoverflow answer every question ever had on php scripting, , it's here learned ajax calls, jquery , javascript related problems. i've got 1 cannot seem find answer to, , i'm not sure doing wrong.

basically, it's shopping cart stores product id in session using ajax call - after ajax call successful shopping cart tray should appear if hidden (when hasnt been set). issue however, basic ajax call breaks. html looks (per product), shortened url's not matter example, link product page:

<article> <a href="#">     <img nopin="nopin" alt="#" src="#"> </a> <h5>     <a href="#">product name</a> </h5> <p class="price">     <a href="#">&euro; 0,00</a> </p>                 <input type="button" name="bestelknop" id="bestelknop" data-id="'.$product['p_id'].'" value="in winkelmandje"> </article> 

i use ajax call parse php file function update cart:

<?php session_start(); if(isset($_post['p_id'])) { $p_id = $_post['p_id']; $_session['cart'][$p_id]++; //add 1 quantity of product id $product_id  } ?> 

the ajax call looks this:

$(document).ready(function() { $("#bestelknop").click(function() {     var p_id = $(this).attr('data-id');      $.ajax({         type : 'post',     url : '/paginas/winkelmandje/toevoegen.php',     data: 'p_id='+p_id,     success : function(data){                 $( "#nav-winkelmandje" ).load('/menu/winkelmandje.php');                  if($( "#nav-winkelmandje" ).is(':hidden')) {        $( "#nav-winkelmandje" ).slidedown();                 }     },     error : function(xmlhttprequest, textstatus, errorthrown)      {alert ("er iets fout gegaan bij het bestellen. druk op f5 en probeer het opnieuw.");}      }); }); }); 

the problem is; first time works. click product's button, ajax call succesfull , resulting div visible (showing have product in cart). when click product, data-id, ajax call not fire @ all. out of idea's why happen, else have clue? element inspection in chrome nor php error reporting gives me errors.

thanks in advance,

stephan

edit: button of first product clicked remains workin. can add more of product session, other buttons not work.

edit 2: buttons not working because used id selector in javascript. have changed class , function fires, in, placed alert see if java called, , is. however, ajax call not fire , still gives no response.

well, fixed it. appearantly php processing page threw offset error due ++ way of altering quantity. added part on checking if [ cart] [product id] exists , handled accordingly, works.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -