Note that there are some explanatory texts on larger screens.

plurals
  1. POPass Array FROM Jquery with JSON to PHP
    primarykey
    data
    text
    <p>hey guys i read some of the other posts and tried alot but its still not working for me. when i alert the array i get all the results on the first site but after sending the data to php i just get an empty result. any ideas?</p> <pre><code>$(document).ready(function() { $('#Btn').click(function() { var cats = []; $('#cats input:checked').each(function() { cats.push(this.value); }); var st = JSON.stringify(cats); $.post('foo.php',{data:st},function(data){cats : cats}); window.location = "foo.php"; }); }); </code></pre> <p>Php</p> <pre><code>$data = json_decode($_POST['data']); </code></pre> <p>THANK YOUU</p> <p>my array looks something like this when i alert it house/flat,garden/nature,sports/hobbies this are a couple of results the user might choose (from checkboxes). but when i post it to php i get nothing. when i use request marker (chrome extension) it shows me something likethat Raw data cats=%5B%22house+themes%22%2C%22flat+items%22%5D </p> <p>i also tried this way-- still no results </p> <pre><code>$(document).ready(function() { $('#Btn').click(function() { var cats = []; $('#cats input:checked').each(function() { cats.push(this.value); alert(cats); $.ajax({ type: 'POST', url: "foo.php", data: {cats: JSON.stringify(cats)}, success: function(data){ alert(data); } }); }); window.location = "foo.php"; }); }); </code></pre> <p>php:</p> <pre><code>$json = $_POST['cats']; $json_string = stripslashes($json); $data = json_decode($json_string, true); echo "&lt;pre&gt;"; print_r($data); </code></pre> <p>its drives me crazy</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. 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