I try to submit a form using Ajax, working in a plugin. I developed two plugins the first one was working but not anymore and I didn’t find any mistakes. I think that is not coming from the code it self but I’m a bit lost.
Here is my 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';
and my 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 ) {
...
}
2
Answers
I was posting files and there were to big,
So in
/etc/php/7.0/apache2/php.ini
increaseTry below code and if it couldn’t work then check following things –
Change URL in below code –
Checklist
your_site_url/wp-admin/admin-ajax.php)
‘html’, ‘xml’ Check what server is delivering you though your
request
Hope this could help. Happy Coding.