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
1
vote
1answer
22 views

Problem with WordPress Ajax form

I am trying to save data from a form to user meta using ajax, however I am unsuccesful. I am pretty new to jQuery, and am not sure where I am going wrong, as there don't seem to be any suntax errors. ...
1
vote
0answers
23 views

WP Ajax never returning any data / calling action

I have a simple click function that gets the data of a radio button in a form and passes it to a function in my functions.php file. The problem is the Ajax never calls my action in my functions.php ...
1
vote
0answers
29 views

Speed/Performance difference between `wp_ajax` and `init` checks for AJAX/POST requests?

Typically, people do ajax calls like: add_action( 'wp_ajax_ACTIONNAME', [$this, 'callback_Function'] ); However, I am interested, what are key differences (other than having authorization checks &...
1
vote
0answers
11 views

Populate dropdown based on selection of parent category

I have a category structure of Places within Regions. I want to show a list of Region categories in a dropdown list then populate a second dropdown of the Places in the first selection in an input ...
1
vote
1answer
28 views

WP_Query inside foreach loop returning same value for all options when filtered using ajax

I am trying to build a timetable to display classes by time. I have a taxonomy of Day, which I am looping over to create a column for each day of the week. In side the column is a WP_Query which ...
0
votes
0answers
18 views

Ajax load shortcode different from page load shortcode

I'm loading a WooCommerce shortcode via ajax which fires and works correctly. However, WooCommerce plugins don't appear to load or be initialised after the ajax call. If I run this shortcode on page ...
0
votes
0answers
26 views

Fragments to Update Cart Counter not working on homepage - Woocommerce

I'm creating a website where the users can add a product to cart (using ajax) from homepage. I'm using a JS function to do this, and it's working. Also, I have a function that updates the custom cart ...
0
votes
1answer
14 views

Update $wpdb query with AJAX

I display a list on my website with a custom database table : $resultats = $wpdb->get_results( $wpdb->prepare( "SELECT photo, nom, prenom, titre_fr, departement_fr FROM {$wpdb->prefix}...
0
votes
1answer
23 views

ajax contact form not submit message

I'm havingo some trouble with a contact form I'm working on. I'm using ajax to submit it and I've noticed that from localhost and from the production server, the test messages I've sent will not be ...
-1
votes
0answers
17 views

Correctly configuring search result page for SearchandFilter Pro plugin

I am trying to have my website filter behaviour replicate this demo: On my page I'm displaying a filter form that I’ve generated with searchandfilterpro plugin that appears in a left hand side custom ...
0
votes
0answers
78 views

do_action add_action in wp_ajax call not executing

In a wp_ajax call I've put some do_action hooks. The add_action for them are not executing My code: add_action( 'wp_ajax_wbulk_update_action', 'wbulk_update_action' ); function wbulk_update_action()...
0
votes
0answers
26 views

Persistent Music Player on a Wordpress/WooCommerce site?

The client wants to sell music and be able to preview audio tracks, but keep the music playing when browsing between pages. Would a full AJAX solution, or Rest API be best? Thinking in terms of ease, ...
0
votes
1answer
40 views

PHP 7.1 | Warning: A non-numeric value encountered in

Warning: A non-numeric value encountered in line 107. <div class="like"> <?php $nonce = wp_create_nonce("my_user_vote_nonce"); $likeLink = admin_url('admin-ajax.php?...
0
votes
2answers
65 views

Ajax is not defined

Stack Exchange long time listener, first time caller. I have found examples on the developer.wordpress site but I have been still struggling. Localizing scripts: wp_localize_script() In my theme's ...
0
votes
2answers
16 views

JS global variable doesn't update

How can i update global variable URL? I am trying for the last 3 days, still no luck var output = ''; var pageNum = ''; url = ''; function post_ajax_get(pagination) { $("#loading-animation")....
0
votes
1answer
44 views

How can I create a button that when clicked populates a div with a list of foods that are checked as a certain type of ACF?

I have not asked any questions here before so I'm sorry if I do it wrong. I am new to custom theme template files. I am new to wordpress and php also. This is a learning exercise for me. I am making a ...
0
votes
1answer
35 views

Woocommerce - Check cart for 2 products, remove 1 if the other is in cart

I have a setup where if the order minimum is $100 a free product is added to the cart. If the customer once again goes below the order minimum the free product is dynamically removed via ajax. I ...
0
votes
1answer
42 views

How to use Datatable with Ajax when creating plugin on WordPress?

Hello i wanted to make a plugin with DataTable integration but i have a problem on calling ajax in url. this is my plugin directory look like. in index.php i use admin_enqueue_scripts for datatable ...
0
votes
0answers
33 views

Programatically Remove Item from Cart Not Working - Needs Page Refresh

I am trying to add a free product to the cart if the order total is above $199.99 I have achieved this and it is working. The issue is that I need to remove the product if the user then deletes an ...
0
votes
0answers
27 views

Filter admin ajax data by url query

I am new on ajax query, How can I filter admin-ajax data in the URL query? I am working on a search page where I am getting all the WordPress user data from admin.ajax.php, that is working fine. ...
0
votes
1answer
34 views

Filter WP user acf field by ajax

I have a search page where search result of user is displaying by postal code or county name. while on the search page i have checkbox to filter user by attribute like developer, designer, and account,...
-1
votes
0answers
30 views

WP post meta isn't called in ajax

Is there a function that resolve the problem to show bool(false) when I call get_post_meta using Ajax. Bool(false) display with a var_dump Otherwise I have nothing. I get this problem only with ajax. ...
0
votes
2answers
41 views

400 Bad Request getting on AJAX Call

I try, when click the submit button then pass the ajax request with some values then calculate that values and return. My Problem : when I make custom Ajax Call then I get 400 error from admin-ajax....
0
votes
0answers
56 views

How to avoid the 403 Forbidden error in a WP Plugin with Ajax and PHP

I've stumbled on the "403 Forbidden error" for which many explanations/solutions can be found in many places, most of them on Stack. However, I struggle for quite a while for solving this error in my ...
0
votes
1answer
26 views

Bad Request in AJAX

I am working in a WordPress plugin. I need help in below AJAX code. // On change division $('body').on( 'change', '.division', function() { $.ajax({ type: "POST", ...
0
votes
1answer
37 views

ajax load more instead of pagination

<?php if ( ! defined( 'ABSPATH' ) ) { exit; } global $wp_rewrite; $wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1; $pagination = array( ...
0
votes
1answer
59 views

Conditionally load public and admin code with AJAX working on both sides

I'm trying to conditionally load my front-end and admin area code, so the file and class that creates admin area will on load on admin side and file and class that is needed to be run on front-end ...
0
votes
0answers
39 views

How to load jQuery with Ajax in WP version 5.3.2?

I am building a custom theme and using wp_enqueue_scripts to load a custom JS file for a specific page template. As you can see I declared jquery as a dependency... function enqueue_theme_scripts() {...
1
vote
2answers
63 views

AJAX Call Via Vanilla JavaScript In WordPress Plugin Development

I ama newbie in WordPress Plugin development in which I have some HTML form on the main plugin page that will get the data from the admin who is logged in and a back page where I have some different ...
0
votes
1answer
20 views

How to get parent comment's id?

I am trying to submit comment in Wordpress with Ajax request, but I am struggling with getting the parent comment's id. Is there any function I can use to get them?
0
votes
0answers
19 views

Locale changed unintentionally during Ajax call through REST API

Edit Found people experiencing the similar issue here. I am using Polylang Pro to build a multilang website. https://wordpress.org/support/topic/updating-current-language-on-ajax-fetched-posts/ I ...
0
votes
1answer
38 views

wp-admin/admin-ajax.php 400 (Bad Request) plugin

There is a strange and frustrating behavior of the wordpress file admin-ajax.php, when I make an ajax request, it returns an incorrect 404 error request. function rp_add_header() { if (is_single()...
0
votes
0answers
23 views

Front end Ajax custom file uploads with multiple file return 404 not found, single file upload working perfectly

in the templete file I gave the below code, <input type="file" name="files[]" id="files" multiple onchange="javascript:updateList()"/> <div id="...
0
votes
1answer
19 views

404 error custom post type rest api

I'm having trouble to get some custom post type using the REST API. I get a 404 message but all the settings are right. Is there a fix? <div class="row services-content"> <?php $services = ...
-1
votes
1answer
32 views

Adding arguments to WooCommerce Product Loop using AJAX

I'm trying to make an AJAX product filter for my WooCommerce shop page. Previously, I had created the query myself, and didn't use the shop page. However, I want to make my code now more WC compatible....
0
votes
0answers
51 views

Filter post by tag

Iive found the next example to make filters on my site by tag: https://www.bobz.co/ajax-filter-posts-tag#comment-28112 But is working not like i spected... I've added on my functions.php: function ...
0
votes
2answers
34 views

How to do the simplest possible frontend ajax call from a plugin?

I'm trying to make this as simple as possible just to get the basics down, but I keep getting a 400 error and 0 response from admin-ajax.php. I just want to hit ajax with some data. Here's my js: ...
0
votes
1answer
74 views

WooCommerce REST API AJAX Auth - 401 response

I need to implement vuejs to load the categories of my store. I've read that the woocoomerce rest api need authenticate requets to work, so I'm trying to get the categories using oauth on localhost ...
0
votes
0answers
16 views

How to add a different html element when the cart has more than 1 product and different when the product count is 0

As per my requirement whenever i have 0 product added on the cart then the page should display a span element with a certain class and when the product quantity is increased from 0 to 1+ then i need ...
0
votes
0answers
31 views

AJAX Post Filter

On my website i made ajax taxonomy filter which is working fine with dropdown select, but i need buttons instead of dropdown. When i am editing code to buttons, filter isnt working, it shows mainc ...
0
votes
1answer
93 views

Can an AJAX callback function access a PHP variable which was defined during initial page load?

I've written a custom plugin. When page-a on my site is loaded: My plugin's main PHP prepares data to send to the page. During execution fo this file, a PHP variable is defined and assigned a value ...
0
votes
0answers
15 views

When calling a function with admin-ajax.php, what is the first parameter? [duplicate]

I'm trying to make a function that can either be called directly or via admin-ajax.php. Strangely, when calling it as an AJAX function, the first parameter's value is a blank string. function ...
0
votes
1answer
48 views

Loading php file with AJAX in Wordpress frontend

Trying out AJAX request for the first time and facing problem. I want to load a php file on button click in Wordpress site. So far after researching, I got this code: index.php file: <button id="...
0
votes
0answers
41 views

admin-ajax.php 403 errors - no caching, permissions are fine

After putting up a recent dev site, I'm met with a very annoying 403 error I can't figure out. It's only an issue with non-WP core widgets (for example, Recent Posts Extended) and I can't add scripts ...
0
votes
0answers
43 views

Errors while using ajax from external wordpress page

I am trying fetch WordPress user data from an external page within same domain using ajax.The problem is i am getting errors which contain the user data and source code from one of my plugin. here ...
0
votes
2answers
24 views

Ajax in plugin fails - but only on one blog - no idea why

this seems hard to understand. I created a plugin, and it works fine on different installations of me and a few other blogs. But on one blog of someone else it fails. After getting through debugs and ...
0
votes
0answers
21 views

Open previous tab when reloading with Bootstrap

I'm having an issue with my site. It has a page with two tabs. In the second tab, there is a pagination and I'm using bootstrap. The issue I'm having is when I click a different page on the pagination,...
0
votes
0answers
31 views

Get User Info without using PHP

Here's my issue: When a user logs in to our WP site, we want to show the user's first and last name next to the login icon on every page (to show that they're logged in and add some personalization ...
0
votes
1answer
34 views

AJAX and custom pages

I have a custom page that I'm using that lets users transcribe archival document and upload them to a relational database (for history research stuff). What I'm trying to do at the moment is add a ...
0
votes
1answer
39 views

Why wp_ajax hooks doesn't work?

I need to execute the Php function from my Ajax form with the POST method. Is there another way instead of ajax hooks? Hooks doesn't execute. Always returning 0. What's wrong? Here's my ajax.js '...

1
2 3 4 5
46