$_GET['s']
will not work for two reason. Firstly you make a POST request and not a GET request and secondly there is no variable with name s
in your request.
When executing an AJAX request through wp-admin/admin-ajax.php
WordPress executes only the code (function) registered to that request. Also it loads WordPress Administration APIs and Ajax Handlers for WordPress Core. So query vars, templates etc are not initialized and that’s why get_search_query() is not working. The flow of an AJAX request is different from the normal one and only the bare minimum is being loaded. You can see wp-admin/admin-ajax.php
for more details of the flow.
Related Posts:
- jQuery UI Autocomplete showing all results
- Filter WP user acf field by ajax
- custom autocomplete search
- Can’t load search results with ajax
- Display full WordPress post under search form using AJAX
- Search function – problem with whole words
- wordpress ajax search posts
- Unexpected WordPress search results
- Ajax live search, “No products found” when the title contains apostrophes and quotations
- Change search to outpout category name instead of Post type name
- AJAX loading with custom parameters
- JavaScript implementation of Gzip
- How to cache json with wp-super cache
- Get Previous & Next posts by Post ID
- ajax – why multiple calls to wp_create_nonce() return same value?
- AJAX request on the frontend always returns 0 if user is not admin
- Admin Notification after save_post, when ajax saving in gutenberg
- Using ajax on categories and wordpress loops
- Cannot load admin-ajax.php. No access-control allow origin*
- Initialize JS with an ajax loaded ACF form
- WordPress Nonce Issue for Ajax Login and Logout
- How to modify wp_ajax function?
- Nonces and Ajax request to REST API and verification
- Vue.js + AJAX Shortcode
- Turn jQuery.ajax() request into XMLHttpRequest (vanilla JavaScript)
- wp_ajax action is not running
- WordPress AJAX calls not detecting language properly?
- AJAX issue – Uncaught SyntaxError when processing Zip File
- wp_verify_nonce doesn’t return true on server when it matches the nonce
- update_user_meta doesn’t work with AJAX
- How do I set the url to make an ajax request for a html document?
- wp-admin AJAX with Fetch API is done without user
- Ajax stops working when logged in?
- Populating content dynamically via AJAX and Advanced Custom Fields [closed]
- Create Page With wp_insert_post() and AJAX
- Load ajax if is_home()
- How to know what page is calling admin-ajax.php?
- Populate a Map at The Same Time as showing Posts via AJAX
- wp_localize_script not working on ajax response
- Get wp_title wp ajax
- Why Does WordPress not output admin-ajax.php path by default?
- SSO autologin WordPress + Ajax
- Speed/Performance difference between `wp_ajax` and `init` checks for AJAX/POST requests?
- Test WordPress api with postman
- How to handle 400 status in Ajax [duplicate]
- Remove trailing 0 from function that is used both statically and dynamically
- How to process wordpress ajax call without action parameter?
- Wp mail does not work when Ajaxed to
- MySQL select query with ajax
- Exposing data using a custom WordPress API
- Use WP admin AJAX url to hide API key
- Custom Login with Ajax not working with IE
- 400 Bad Request when sending XHR from React.js to admin-ajax.php
- How can I wp_send_json data?
- Making POST request with AJAX returns a 400 error (without jQuery)
- Load image src through Ajax by ID?
- Using get_theme_mod in php ajax form doesn’t work
- PHP session when called wp_ajax_nopriv
- What exactly does ‘authenticated’ mean for wp_ajax_nopriv?
- Use AJAX in a WordPress Plugin to Get Data From Custom Database?
- Custom RPC end-point security best pratice?
- How to make image in TinyMCE clickable
- How to use Jeditable plugin with admin-ajax.php?
- Ajax mousedown call getting “cancelled” when clicking link
- WordPress Ajax Not Firing
- Get uploaded attachment width & height and attachment ID after upload them
- Disabling ajax code that does a POST request that ends in a 400 error code
- Refresh checkout fields on add to cart with order bump
- Add Server Side validation in Ajax mail form
- Is it good practice to use REST API in wp-admin plugin page? [closed]
- How to prevent my external API call from being called by anyone but me (my site)
- Ajax not sending the data correctly- Multidimensional array
- get a bad request 400 on my ajax-admin.php file
- Registration form AJAX check for existing username (simple version)
- How to check Ajax request only when i opened the Notifications list?
- All WordPress AJAX calls always return 0
- Trigger action via button
- Syntax error on query_vars while handling with Jquery
- Want to send ajax request in wordpress to a custom file in plugin
- How to send the checkbox value to email
- how to get password from user instead wp-generate-password
- Class called in template, AJAX not registering
- Same query in category.php and in function.php, but different result
- How to use nonces for frontend AJAX voting if the page gets cached?
- AJAX Call in Plugin Returns More than JSON
- Ajax take too long to return code
- problem when adding wp_editor with ajax [duplicate]
- Get wp-load.php PATH with wp_localize_script and JavaScript for plugin
- Ajax Form seems to post, but does not return
- Ajax request to admin-ajax.php and window.location.href
- Objects and get_post_meta() gives me 1 string for latitude and longitude
- delete attachment for one post without deleting actual attachment post
- Memberpress isn’t cooperating with WooCommerce
- where does my function output from load-* go?
- WordPress ajax requst returns zero
- wp_editor() in content that was loaded with ajax [duplicate]
- WordPress blocking polling request when signed into Admin
- Send button using own contact form [closed]
- Front-end ajax problem all users and guests getting a 302 redirect when accessing wp-admin/admin-ajax.php
- Use Ajax to get an Options Settings Value