• Hi guys this is the code from this plugin init.php file, basically adds script to the head of the wordpress.

    function wpas_scripts() {
        wp_enqueue_script( 'wpas-scripts', get_wpas_uri() . '/js/scripts.js', array('jquery'), '1', false );
        wp_enqueue_script( 'wpas-admin-ajax', admin_url( 'admin-ajax.php' ), array(), '1', false );
        wp_localize_script( 'wpas-admin-ajax', 'WPAS_Ajax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
    }
    add_action('wp_enqueue_scripts', 'wpas_scripts');

    so it causing this error in the console:
    wp-admin/admin-ajax.php?ver=1 400 (Bad Request)
    failing to load resource
    or this:
    wp-admin/admin-ajax.php?ver=1 net::ERR_ABORTED

    So basically i guess somehow it blocks the access to this file and throws an error.
    Is there any way to fix this, like exception in functions.php or something?

    I have to invoke this script in the plugin, otherwise it is not working,

    • This topic was modified 6 years, 11 months ago by aosipov.

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • This is just a (wild) guess mind you, but your current robots.txt file is as follows:

    User-agent: *
    Disallow: /wp-admin/

    A default WordPress virtual robots file would usually look like this:

    User-agent: *
    Disallow: /wp-admin/
    Allow: /wp-admin/admin-ajax.php

    While I’m not 100% sure it would actually cause a 400 error, you might try adding
    Allow: /wp-admin/admin-ajax.php to your robots file and see if the symptom goes away or changes at all.

    Thread Starter aosipov

    (@aosipov)

    Thank you Clayton, but i think this is not an issue, my website is running local, this is the site with the plugin: https://wpadvancedsearch.com/.

    still struggling with that:)

    Moderator bcworkz

    (@bcworkz)

    I believe a malformed Ajax request causes 400 errors on admin-ajax.php. A missing “action:” parameter for example. You should seek assistance from the WPAS devs: https://wpadvancedsearch.com/help/

    Thread Starter aosipov

    (@aosipov)

    Yeah, this thing is not supported anymore:(
    How usually you fix this type of error…

    Moderator bcworkz

    (@bcworkz)

    Unfortunately, 400 errors are one of the least informative. Use your browser’s network developer tool to see the actual request causing the 400. Something is wrong, either in sent headers or sent parameters. Seeing what’s missing or wrong can be a challenge, you need to be familiar with what the target code is expecting. For Ajax calls it’s primarily the existence of an action: parameter. Also be sure the headers sent are appropriate for Ajax (content type for example).

    It’ll help if you can compare network data with a very similar, working Ajax request. Once you identify what is wrong, find the code responsible and alter it to correct the problem. Easier said than done!

    d

    (@dnicinski)

    I have the same issue.

    How about this?

    1) Comment out the middle wp_enqueue_script in init.php —

    line 42:
    // wp_enqueue_script( ‘wpas-admin-ajax’, admin_url( ‘admin-ajax.php’ ), array(), ‘1’, false );

    2) Then inside js/scripts.js —

    line 156:
    replace
    url: WPAS_Ajax.ajaxurl,
    with
    url: “/wp-admin/admin-ajax.php”,

    The error is gone for me and everything seems to be working fine.

    Hope this helps.

    Good afternoon, I have the same problem with the theme of kayllas
    wp-admin / admin-ajax.php 403 (Forbidden)
    they solved it?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Plugin (wpas) causing admin-ajax.php error’ is closed to new replies.