那不是在wordpress中实现ajax的方法。所有ajax请求都应发送到
admin-ajax.php。
在您的模板文件中:
<script type="text/javascript">var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>';</script>在您的js中:
$.ajax({ url: ajaxurl, type: "POST", cache: false, data: data + '&action=sendmail' //action defines which function to use in add_action});在您的functions.php中:
function send_my_mail(){#do your stuff}add_action('wp_ajax_sendmail', 'send_my_mail');add_action('wp_ajax_nopriv_sendmail', 'send_my_mail');了解有关
Ajax in Plugins。



