Getting 400 Bad Request on developing Ajax Plugin

I am trying to create a plugin using Ajax in WordPress. In my plugin page I have

add_action( ‘wp_enqueue_scripts’, ‘ajaxify_enqueue_scripts’ );
function ajaxify_enqueue_scripts() {
wp_enqueue_script( ‘ajaxify’, get_template_directory_uri() .’/js/ajaxify.js’, array(‘jquery’),’1.0′,true );
wp_localize_script( ‘ajaxify’, ‘postlove’, array(‘ajax_url’ => admin_url( ‘admin-ajax.php’ )));

in ajaxify.js I have

jQuery( document ).on( ‘click’, ‘#up-data’, function() {
url : postlove.ajax_url,
type: “POST”,
dataType: ‘html’,
data : {
action : ‘set_ajaxify’,
domain : ‘’
success : function( response ) {
jQuery(‘.result’).html( response );

and in admin-ajax.php I have

add_action( ‘wp_ajax_nopriv_set_ajaxify’, ‘set_ajaxify’ );
add_action( ‘wp_ajax_set_ajaxify’, ‘set_ajaxify’ );

function set_ajaxify() {
$_SESSION[“domain”] = $_POST[“domain”];
echo $_SESSION[“domain”];

but I am getting

POST http://localhost/WP/wp-admin/admin-ajax.php 400 (Bad Request)

can you please let me know how to fix this?

Read more here:: Getting 400 Bad Request on developing Ajax Plugin

Leave a Reply

Your email address will not be published. Required fields are marked *