是的,请使用内置的wordpress ajax操作:
您的jquery将如下所示:
$('#ajax_form').bind('submit', function() { var form = $('#ajax_form'); var data = form.serialize(); data.action = 'MyPlugin_GetVars' $.post('/wp-admin/admin-ajax.php', data, function(response) { alert(response); });return false;您的插件代码如下:
add_action("wp_ajax_MyPlugin_GetVars", "MyPlugin_GetVars");add_action("wp_ajax_nopriv_MyPlugin_GetVars", "MyPlugin_GetVars");function MyPlugin_GetVars(){ global $wpdb; // use $wpdb to do your inserting //Do your ajax stuff here // You could do include('/wp-content/plugins/test/getvars.php') but you should // just avoid that and move the pre into this function}


