【发布时间】:2020-09-30 09:14:55
【问题描述】:
我尝试使用 Ajax 在插件中提交表单。我开发了两个插件,第一个可以工作,但现在不行了,我没有发现任何错误。我认为这不是来自它自己的代码,但我有点迷茫。
这是我的 php:
wp_enqueue_script( 'b_form', plugin_dir_url( __FILE__ ) . 'js/b-form.js', array( 'jquery') );
wp_localize_script( 'b_form', 'ajax_url', admin_url( 'admin-ajax.php' ) );
include plugin_dir_path( __FILE__ ) . 'pages/b-form.php';
还有我的 js:
var fd = new FormData( document.getElementById( 'b_form' ) );
fd.append( 'action', 'b_generate_comparison' );
$.ajax({
type: "POST",
url: ajax_url,
data: fd,
contentType: false,
processData: false,
})
.done( function( response ) {
...
}
.fail( function( response ) {
...
}
.always( function( response ) {
...
}
【问题讨论】:
-
服务器端 php 日志中有任何信息吗?
-
确实,收到了正确的消息错误,谢谢,我没想到会到达那里
标签: javascript php jquery ajax wordpress