注册用于提交电子邮件的ajax操作:
笔记handle_form
是此示例中操作的名称
add_action(\'wp_ajax_handle_form\',\'handle_form_submit_111605\' );
还要添加此选项,以使其适用于未登录的用户
add_action(\'wp_ajax_nopriv_handle_form\',\'handle_form_submit_111605\' );
在回调函数handle\\u form\\u submit\\u 111605中执行验证和邮件发送作业
在里面functions.php
function handle_form_submit_111605() {
}
用户只需jquey ajax通过ajaxIn you js文件提交表单
<script type="text/jaascript">
var submitdata = myForm.serialize();
jQuery.ajax({
url: \'http://domain/wp-admin/admin-ajax.php?action=handle_form\',
//action parameter is the same one you used while registering the ajax
type: \'POST\',
data: submitData,
success: function(data, textStatus, xhr) {
if(data.status){
// ...
}
}
});
</script>
查看更多信息
here