有一個簡單的表單(這裏只提取字段),但由於某種原因,JQserilization不起作用;在alert()中看起來很好,但只有第一個表單字段獲取帖子。建議請及時 - 在此先感謝Jquery序列化不起作用
形式:
<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;
});
});
而且PHP處理
if(isset($_POST['newevent'])) :
$insert = mysql_query("INSERT INTO events (event_options) VALUES ('".$_POST['event_options']."')");
endif;
有什麼建議?
你應該避免從後到查詢直接串聯。非常危險的sequrity問題 – fmsf 2010-04-12 13:48:48