Trying to send an array from:
<select name='galaddvenn[]' class='sel_add vl hidden' multiple='multiple'>
<option value='53'>name1</option>
<option value='352'>name2</option>
<option value='632'>name3</option>
<option value='543'>name4</option>..etc
</select>
…to/from Jquery with:
var ar = $("select#galaddvenn").serialize();
j.ajax({
data: ({ar : ar}), //tried with 'ar':ar
dataType: "html",
type:"post",
url: "/ajax_gal_addvenn.php",
cache: false,
….etc
to PHP:
if(isset($_POST['ar'])){
$ar = mysql_real_escape_string($_POST['ar']);
var_dump($ar);
Gives me: bool(false) 🙁
What am i doing wrong here?
.serialize()gets a complete POST string by itself, so it’ll be formatted like this:So your call should look like this:
Then on the PHP side, you’re looking for
$_POST['galaddvenn']instead.You can test the output here.