Questions tagged [ajax]

Ajax - The core of WordPress uses Ajax only in the administration screens. For instance, Ajax is used for instant updates when you are doing comment moderation, and when you are adding and deleting items from lists such as categories, blogroll, and posts; Ajax is also the technology behind the auto-save functionality on post and page editing screens. Several themes and plugins also use Ajax; for instance, some post rating plugins.

Filter by
Sorted by
Tagged with
0 votes
1 answer
892 views

Upload multiple files via ajax from an HTML file input

I'm trying to upload files from a multiple file upload HTML input via ajax on a WordPress site but I keep getting a 400 error and I'm not sure why. My code is based on this tutorial. jQuery: $(...
AJT's user avatar
  • 187
1 vote
1 answer
261 views

How to handle Ajax Calls, when using same shortcodes (with different parameters, e.g. 'post-type')?

this is my very first question here. So please don't be too angry, if I miss something out or make mistakes while using the plattform. I was, of course, trying to find an answer on my problem first. ...
Diddi_83's user avatar
0 votes
1 answer
120 views

Load posts via AJAX without draft status

When I load posts in the frontend via AJAX, I also see posts that have the status "Draft": function get_projects() { $args = array("post_type" => "project"); $...
Jonas's user avatar
  • 159
1 vote
0 answers
470 views

WordPress Ajax search filter on dropdown select

I am trying to create search filter on click dropdown selection, but still not achieved, here is my code. Here is form code, which contains three different dropdwon <form id="filter-form"&...
Parth Ranjan's user avatar
0 votes
0 answers
133 views

AJAX search function resets wp_query vars

I have a custom post type called event. On the archive page I implemented a simple search which returns a selection of posts. Before submitting the search form I'm seeing the proper query vars for the ...
Hewe's user avatar
  • 75
2 votes
0 answers
147 views

AJAX returning blank result

I'm using ajax to filter a list. The filter works as it should most of the time, but for some queries it returns a blank result. When this happens, the error in the console is: PHP Errors in Ajax ...
Jillian Hoenig's user avatar
0 votes
1 answer
383 views

Woocommerce - Include custom user meta in order 'filter by registered customer' Ajax search

I am trying to include a users custom meta named 'sageaccountnumber' within the 'filter by registered customer' section of the WooCommerce orders list as shown below: I already have the custom meta ...
DSmit's user avatar
  • 1
0 votes
1 answer
35 views

how can i create get request unis ajax without expecting return value

this is my Code and when i run it i become the error parseerror. In my case i dont need a return Value, but i will just run the method. Order.prototype._downloadDetails = function () { ...
mahmoud abdelberi's user avatar
1 vote
0 answers
285 views

WordPress Ajax load doesn't work

Hello I have set up custom Ajax load more without plugins, but it’s only showing 3 posts on home page, and when clicking on button to load more it’s not loading anything. As I am a beginner I am ...
Ferdal Karaman's user avatar
1 vote
1 answer
423 views

getJSON response to PHP

I am working on a project where i must call a 3rd party API from client-side then process the response in PHP before displaying it in on the front end. So i planned it in my head like this: use ...
k33n's user avatar
  • 31
0 votes
1 answer
556 views

Bad Request 400... jQuery ajax post of json data to wordpress admin-ajax.php

I've tried and tried and tried, I've searched and searched... I can't figure out why this isn't working. One huge problem is I can't seem to figure out how to get any good debug info about why this is ...
Dustin's user avatar
  • 1
0 votes
0 answers
43 views

Access to a data from a response AJAX called in a template file php

I use an ajax called to get all posts of a custom post type and other criteria. I would like to get the response of my ajax called and use it in a template php file. So my question is : how can I pass ...
davidb45's user avatar
0 votes
0 answers
150 views

Woocommerce ajax search can't work on mobile

It's wired my ajax search code can work on the desktop, but in the mobile browser, the ajax search doesn't have any responses. I don't know how to get the trick. html <input type="text" ...
Pearson's user avatar
0 votes
1 answer
1k views

Remove Woocommerce product from cart with ajax/fetch [closed]

I have a problem with removing products from the cart in Woocommerce and I think it has to do with WC_Cart::remove_cart_item. I only get these error messages: POST http://localhost:3000/esport/wp-...
Ulvar's user avatar
  • 3
1 vote
1 answer
752 views

Why my admin-ajax url returns 0 even after adding echo and die() at the end of function?

I have read about more than 10 answers that recommends using action in data and adding echo and die at the end of function. But still I am getting error of bad request. If I directly open the URL &...
Amir Sandila's user avatar
0 votes
1 answer
552 views

How do I call an action hook into wp_ajax hook callback function

I have to trigger an ajax call based on a custom field changes on checkout form which is to add a discount. But if I call the hook to add discount into subtotal of the cart it does not do anything. ...
Fahad's user avatar
  • 54
1 vote
1 answer
272 views

ajax problems on loading page [closed]

I wrote a code that when a user click on a button. contents will be displayed via ajax in wordpress. I used wp_ajax_{action} and wp_ajax_nopriv_{action}. when I load the page ajax run without any ...
wprah's user avatar
  • 46
0 votes
0 answers
62 views

Internal Server Error when echoing an OBJECT from wp ajax action function in functions.php to JS file

I'm using Elementor Pro as my page builder. I'm trying to create a Job Post filter using Elementor forms. Issue is when I echo and return an Object type from the functions.php file to the JS file. It ...
shimii's user avatar
  • 15
0 votes
0 answers
61 views

Inline AJAX script passing variables to PHP

I'm creating Referral URL detection plugin. I need that WP plugin enqueue AJAX script inline, which calls/pass variables to PHP script. When I trying to add same code to theme everything works (...
eatmailyo's user avatar
  • 101
0 votes
2 answers
76 views

wordpress ajax bad request 400

Where is my mistake? html code <div class="star-rating"> <span class="postid" post-id="52"></span> <span class="score-bg"></span> &...
Tara's user avatar
  • 43
-1 votes
1 answer
20 views

Select posts from list and add them in a new list

There is this fanduel website webpage with functionality to add players from left to selected players list in the right. Also when we click on filtering by position they are filtered without reloading ...
Broly LSSJ's user avatar
0 votes
1 answer
54 views

Add "load more" functionality to an AJAX response

We have a custom post type named accommodation and it has one taxonomy, named accommodation_city. Its children are 4 terms, simple city names. What I have done so far, is make 2 queries: Will show ...
dominotrix's user avatar
2 votes
1 answer
1k views

WordPress Ajax send response on every iteration of a loop

I am trying to get an ajax request to update the response as it goes through a loop, similar to a progress bar. A bit of background on this snippet. Here is the JS Ajax request: // ------------...
sallycakes's user avatar
0 votes
1 answer
728 views

PHP cookie not set within AJAX call

I'm trying to set a cookie within an AJAX call after I get the response of an API. The API and AJAX call are working fine, but the cookie is not being set. I used the 'COOKIEPATH' and 'COOKIE_DOMAIN' ...
Loosie94's user avatar
  • 231
0 votes
0 answers
140 views

Correct way to perform a GET to another PHP file hosted on wordpress

When performing a GET from inside a .PHP file that is part of a short code is there a way (or a correct way) to reference another PHP file in the same folder For example I have a shortcode that uses a ...
Tim Bowers's user avatar
0 votes
1 answer
104 views

Wordpress Ajax - looping data into a table

Can anyone tell me what I did wrong? I made an ajax call in wordpress to loop through data to display the results on a table. Here is my php: function DisplayInfo() { global $wpdb; $...
John Lyons's user avatar
0 votes
1 answer
82 views

notify users when changed database

I want to be notified when a meta from the database changes. In fact, I built a chat system with Ajax and currently this Ajax is executed every 2 seconds and if there is a new message, it displays it. ...
peyman jalili's user avatar
1 vote
1 answer
583 views

wordpress Ajax success doesn't return the value

I have created a plugin where I am recieving the data via rest url and I am getting the correct output when I use var_dump($final_price_return); and no return in success call. PHP code that returns ...
Naik Javaid's user avatar
0 votes
0 answers
39 views

How to use url and amin-ajax.php

I am trying to redirect users back to a main page with a success message after the submit button with php and ajax. However, the users are sent to a blank page with the message. I believe it has to do ...
John Lyons's user avatar
0 votes
0 answers
61 views

$wpdb Ajax not redirecting to main page

I'm having difficulty with redirecting a page once a person submits data. I made a form, and when the user clicks 'Add student', the data would be encoded through json, stored in the database. The ...
John Lyons's user avatar
0 votes
0 answers
587 views

WP - Ajax call back data printed in the console.log

Edit 3: Another Ajax call in admin_footer testing 1244 is in the callback function Edit 2: These all request have been made Edit: this the result of the php function inside the console log which ...
Steve's user avatar
  • 37
0 votes
1 answer
157 views

Call pre_get_posts inside ajax

Is it possible to run pre_get_posts inside the ajax callback? I want to change the query after the ajax run here my code function repeater_dynamic_query( $query ) { global $post; if ( $query->...
Baim Whello's user avatar
1 vote
0 answers
63 views

Jquery post responses 500 error after some time and lastly an 503 error

I'm currently developing a wordpress plugin that fetches product attributes from 3rd API and creates WooCommerce products using these attrs. I wrote two different jquery post function nestedly. The ...
Artificial Inheritance's user avatar
0 votes
1 answer
80 views

wp_enqueue_scripts with JS script as a string

isn't there any way to load a script through wp_enqueue_scripts and have my script instead of in a file, in a variable declared earlier? Something like: add_action('wp_enqueue_scripts', '...
Faye D.'s user avatar
  • 126
0 votes
0 answers
165 views

how reduce fetch/XHR response time

i using this code for ajax requset front code: function ajax_request() { jQuery(document).ready(function () { $.ajax({ url: ajaxurl, type: 'POST', ...
hossein khosromanesh's user avatar
0 votes
0 answers
79 views

Wordpress error

Hell, I have an error: Fatal error: Uncaught Error: Call to undefined function apply_filters() in /home4/smakolyk/public_html/pcwordpress/wp-content/plugins/woocommerce/includes/admin/importers/...
Jakub Troczyński's user avatar
0 votes
1 answer
137 views

How to call php file in theme directory from plugin

The goal is to reuse some part of code to login and logout user in ajax with or without reload page . I can't call the content of php file ajax_user.php inside wordpress template directory from my ...
imagIne's user avatar
  • 53
0 votes
0 answers
61 views

Need help creating asynchronous data scraper in WordPress

I need some help on a data scraping script I've been working on. I want to create a script through which content can be extracted from a page. I fetched the page via wp_remote_get() and ...
Divjot Singh's user avatar
0 votes
0 answers
165 views

How to split AJAX response into two divs

How I could get AJAX response splitted in two separate divs? Situation: I have custom post type (case-studies) filter by custom taxonomy(case study category). On page load I query by exact category. ...
Get_Date's user avatar
0 votes
1 answer
537 views

How to set variables with AJAX request to use in another function in WordPress

$.ajax( { method : 'POST', dataType : 'json', url : my_var.ajaxurl, data : { foo : foobar, ...
Muhammad Hossain's user avatar
0 votes
1 answer
176 views

Problems implementing Load More functionality

I’m trying to create my own Load More functionality (on click) in my child theme using the latest standards in Wordpress. I’m not comfortable working with the php parts of things and I’m getting very ...
Seblito's user avatar
  • 29
0 votes
0 answers
903 views

admin-ajax.php returns 0 even when the post status code is 200 OK

I've seen a lot of similar questions and I've incorporated the feedback from the answers but still, the issue is not resolved. Ajax request is sent on click of a button in js file. WyrRoute.js ...
Patrick2997's user avatar
0 votes
0 answers
2k views

admin-ajax.php error 500

I keep looking my error , but I can't find it. My php and js script works fine 5 month ago when I let them to dedicate myself to design Normally this ajax query must be launch from my plugin ( and ...
imagIne's user avatar
  • 53
0 votes
0 answers
218 views

admin-ajax.php 500 error when new users try to register

I have WordPress website and I get admin-ajax.php 500 error when new users try to register. jquery.min.js?ver=3.6.0:2 POST https://example.com/wp-admin/admin-ajax.php 500 send @ jquery.min.js?...
flytomoon777's user avatar
0 votes
1 answer
64 views

Why Wordpress AJAX returns undefined however it works fine when I add static url instead of dynamic function?

Code from functions.php function university_files() { wp_localize_script('main-university-js', 'universityData', array( 'root-url' => get_site_url() )); }; add_action('...
Huzaifa Qayyum's user avatar
1 vote
1 answer
2k views

woocommerce search by sku and title ajax

This snippet works only in Title and i need to add also in Metakey SKU. <?php // Ajax Search. function thb_ajax_search() { check_ajax_referer( 'thb_autocomplete_ajax', 'security' ); $...
DK Thakur's user avatar
  • 149
0 votes
0 answers
111 views

Why does PHP called with Jquery AJAX not allow additional php code to be added?

I wrote a plugin a few years ago that successfully uses AJAX and then recently I tried to add more of the same functionality but it fails. In the PHP files, I localized admin-ajax into the JQuery ...
brothman01's user avatar
0 votes
1 answer
183 views

Error sending array data from php to javascript

Sorry i see that here is heap of similar questions, but i will be dare to ask the same. I'm sending javascript two dimensional array to PHP script and then it saved to database. I'm using JSON....
Taras Parashchuk's user avatar
0 votes
0 answers
119 views

Wordpress Ajax Not Firing

I've been out of the WordPress game for a while now and I'm just getting back into it. I'm trying to practice calling a PHP function via Ajax but I'm not able to get the Ajax call to even fire (when ...
Morts81's user avatar
  • 123
0 votes
1 answer
121 views

Message notification for user

I want to create alert system for users. If user get message I want to show info andout it near user image in header. So I create table for message id_message | id_user | sender_name | sender_email | ...
flytomoon777's user avatar

1 2
3
4 5
54