Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery .load() doesn't give HTML back (with a " " space in the URL!)
    primarykey
    data
    text
    <p>I am working on a webshop for school.I'm trying to make an <code>jquery/ajax</code> cart system.</p> <p>Now this is my <code>jquery.load();</code> code</p> <pre><code>//LOAD PHP FUNCTION TO ADD TO CART $("#cart_page").load("cart.php?command=addToCart&amp;productID="+productID+"&amp;size="+size+"&amp;amount="+amount+"&amp;product_name="+product_name+""); </code></pre> <p>This is the cart.php file:</p> <pre><code>&lt;?php //ADD PRODUCTS TO CART if($_GET['command'] == 'addToCart'){ /********* START SESSION *********/ session_start(); if($_GET['productID'] == "" || $_GET['amount'] &lt; 1 || $_GET['size'] == "" || $_GET['product_name'] == "") return; $max=count($_SESSION['cart']); if(is_array($_SESSION['cart'])){ $max=count($_SESSION['cart']); for($i=0;$i&lt;$max;$i++){ if($_GET['productID'] == $_SESSION['cart'][$i]['productid']){ if($_GET['size'] == $_SESSION['cart'][$i]['size'] ){ $product_exists = 1; } } } if($product_exists != 1){ $_SESSION['cart'][$max]['productid'] = $_GET['productID']; $_SESSION['cart'][$max]['product_name'] = $_GET['product_name']; $_SESSION['cart'][$max]['amount'] = $_GET['amount']; $_SESSION['cart'][$max]['size'] = $_GET['size']; } }else{ $_SESSION['cart']=array(); $_SESSION['cart'][0]['productid'] = $_GET['productID']; $_SESSION['cart'][0]['product_name'] = $_GET['product_name']; $_SESSION['cart'][0]['amount'] = $_GET['amount']; $_SESSION['cart'][0]['size'] = $_GET['size']; } if(is_array($_SESSION['cart'])){ $max=count($_SESSION['cart']); $cart = &lt;&lt;&lt;EOD &lt;div class="cart_page"&gt; &lt;div class="cart_product_line"&gt; $max &lt;ul&gt; EOD; for($i=0;$i&lt;$max;$i++){ $arrayID = $i; $cart_productID = $_SESSION['cart'][$i]['productid']; $cart_productName = $_SESSION['cart'][$i]['product_name']; $cart_amount = $_SESSION['cart'][$i]['amount']; $cart_size = $_SESSION['cart'][$i]['size']; $cart.= &lt;&lt;&lt;EOD &lt;li&gt;$arrayID&lt;/li&gt; &lt;li&gt;$cart_productID&lt;/li&gt; &lt;li id="$cart_productID"&gt;$cart_productName&lt;/li&gt; &lt;li class="amount"&gt;$cart_amount&lt;/li&gt; &lt;li class="size"&gt;$cart_size&lt;/li&gt; EOD; } $cart.= &lt;&lt;&lt;EOD &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; EOD; } } echo $cart; ?&gt; </code></pre> <p>Now it does everything i want it to. But the result it gives in <code>'echo $cart.php'</code> doesn 't get displayed in my index.php</p> <p>can you guys help me out please?</p> <p>PS:</p> <p>if i go to:</p> <blockquote> <p>cart.php?command=addToCart&amp;productID=28&amp;amount=10&amp;size=12&amp;product_name=Test</p> </blockquote> <p>It gives this back</p> <pre><code>1 0 28 Test 10 12 </code></pre> <p>in HTML so the script works and gives html back! I'm doing the same with loading products and there it works like a charm.</p>
    singulars
    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.
 

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