Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I recommend you to take a look at <a href="http://api.jquery.com/jQuery.post/" rel="nofollow">jQuery.post() method</a> of jQuery library.</p> <p>Let's see the following example: </p> <p>Javascript code:</p> <pre><code>$("#submit-button").click(function(){ $.POST("/PATH_TO/update_cart.php", {product_id:$('#product-id').val(),quantity:$('#quntity').val()}, function(data){ if(data.success) { $("#form-field-id").val(data.some_returned_value); // update value of an text input or textarea (view more info about jQuery selectors) $("p#form-p-id").html(data.some_other_returned_value); // update value of a paragraph } }, 'json'); }); </code></pre> <p>For more info about <strong>jQuery Selectors</strong> please <a href="http://api.jquery.com/category/selectors/" rel="nofollow">check this</a></p> <p>PHP code:</p> <pre><code>&lt;?php $success = false; if(loged()) { // verify if the user is loged (if it's needed) if(!empty($_POST['product_id']) &amp;&amp; is_numeric($_POST['product_id']) &amp;&amp; !empty($_POST['quantity']) &amp;&amp; is_numeric($_POST['quantity'])) { // use here your additional code // update database // if every condition is applied then confirm that the fields are updated $success = true; $some_returned_value = "data has been successfully updated"; $some_other_returned_value = 45.3; // the final price } } echo json_encode(array("success" =&gt; $success, "some_returned_value" =&gt; $some_returned_value, "some_other_returned_value" =&gt; $some_other_returned_value)); ?&gt; </code></pre> <p>This is a simple example about how you can use jQuery POST method and PHP for updating data you want. I didn't use any of your code, but you can try to update your cart like this. jQuery is a powerfull library, so I'll recommend you to take a look at it.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload