通过WordPress,我构建了一个成功的AJAX响应表单。数据库中的字段是空虽然!我猜这是因为我没有序列化我的值:为AJAX序列化表格值
// JavaScript Document
jQuery(document).ready(function($){
jQuery('#newFeedbackForm').submit(function(){
var topic = $('#topic').val();
var name = $('#name').val();
var email = $('#email').val();
var no_results_feedback = $('#no_results_feedback').val();
var post_data = {
action: 'addFeedback',
topic: topic,
name: name,
email: email,
no_results_feedback: no_results_feedback
};
$.post(av_feedback_vars.ajaxurl, post_data, function(response){
if(response == 'success'){
$('#feedback').text('Thank you for your comment.');
}else{
alert(av_feedback_vars.error_message);
}
});
return false;
});
});
如何在这种情况下使用序列化?感谢您帮助noob(第一次在这里的ajax)
+0
'alert(post_data)'看看它是否为空 –
+0
这将打印'[object Object]'...没用。 –