Jquery Serialization not working

Posted by RussP on Stack Overflow See other posts from Stack Overflow or by RussP
Published on 2010-04-12T13:34:24Z Indexed on 2010/04/12 13:43 UTC
Read the original article Hit count: 226

Filed under:
|
|

Have a simple form (only extract fields here) but for some reason the JQserilization is not working; looks fine in alert() but only the first form field gets posts. Suggestions please - thanks in advance

Form:

<form id="neweventform" method="post" action="">
<div class="grid_4 alpha">Setup date *</div>
<div class="grid_7 omega">
<select name="setup_day" id="setup_day"><?php days_list(); ?></select>
<select name="setup_month" id="setup_month"><?php month_list(); ?></select>
<select name="setup_year" id="setup_year"><?php year_list(); ?></select> 
<div class="grid_11">
<input type="submit" name="createevent" value="Create" id="createevent" />
</div>
</form>

Jquery

$j(document).ready(function(){
$j('#neweventform').live('submit',function () {
var data= $j('#neweventform').serialize();
alert(data);
$j.ajax({type: "POST", url: "scripts/process.php",data: "newevent=newevent&event_options=" + data, cache: false, complete: function(data){ 
$j('#neweventform').fadeOut(2000),loading.fadeOut('slow'),$j('#content').fadeIn(2000), $j('#content').load('scripts/events.php #eventslist'); 
}
});
return false;
});
});

And the PHP processing

if(isset($_POST['newevent'])) :
$insert = mysql_query("INSERT INTO events (event_options) VALUES ('".$_POST['event_options']."')");
endif;

Any suggestions?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about serialization