Javascript Ajax与wordpress,400错误请求
我尝试使用Ajax提交表单,使用插件。我开发了两个插件,第一个正在工作,但不再工作,我没有发现任何错误。我认为这不是源于代码本身,但我有点迷路了 以下是我的php:Javascript Ajax与wordpress,400错误请求,javascript,php,jquery,ajax,wordpress,Javascript,Php,Jquery,Ajax,Wordpress,我尝试使用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' ) )
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 ) {
...
}
尝试下面的代码,如果无法工作,请检查以下内容- 在下面的代码中更改URL-
var fd = new FormData( document.getElementById( 'b_form' ) );
fd.append( 'action', 'b_generate_comparison' );
$.ajax({
type : 'POST',
url : 'http://YOUR_SITE_URL/wp-admin/admin-ajax.php',
dataType : 'json',
data: fd,
contentType: false,
processData: false,
success : function( response ) {
.done( function( response ) {
...
}
.fail( function( response ) {
...
}
.always( function( response ) {
...
}
} // success
}); // Ajax request end
检查表
希望这能有所帮助。快乐的编码。我在上传文件,而且有很多 因此在
/etc/php/7.0/apache2/php.ini中增加
upload_max_filesize = 13M
post_max_size = 27M
服务器端php日志中有任何信息吗?事实上,得到了正确的消息错误,感谢我没有想到要到达那里