The Stack Overflow podcast is back! Listen to an interview with our new CEO.

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
0answers
6 views

Update / refresh mini cart, after custom AJAX add_to_cart event

I need help In my custom single-product.php template, I added the button public function AddToCartButton() { global $product; if($product->is_type('variable') || $product->...
1
vote
0answers
18 views

Solve cors problem using rest api or ajax

I'm building an app with nuxt using WP as a CMS, so I have this code in my functions.php to allow any origin (temporary) using the rest api and admin-ajax urls function add_cors_http_header(){ // ...
0
votes
0answers
30 views

wp_ajax_ 400 Bad Request

Trying to run a ajax request back to a function and keep getting a 400 error. this is the code below wp_register_script('frontend_js', plugins_url('/js/frontend.js', __FILE__), array(), false, ...
0
votes
0answers
11 views

Load MediaPlayerElement after Infinity Scroll loads more posts

I am using Infinite Scroll on a site that is using a custom styled MediaPlayer Element (using Wordpress' built-in MediaElements.JS). The style initially loads fine, but once Infinite Scroll loads ...
1
vote
1answer
16 views

Using Ajax to load more posts | Help me change the wording on my button to notify the user

I am having bit of a brain melt situation trying to carry across a style of code I used on a previous website where I would change the wording on the button the user clicks to load more. I have ...
0
votes
0answers
31 views

AJAX content that only appears while the customizer is open

While this is likely specifically a WooCommerce issue, it still applies here. I am using the AJAX add-to-cart feature, so, upon clicking "add to cart," items should be added to the cart (this part ...
0
votes
0answers
11 views

Suggested JS Framework for WP Plugin Development

Currently, when creating WP Plugins, I use a lot of basic JS, with jQuery and ALOT of AJAX requests… Can you please suggest a framework that I can use instead that will make things much easier and ...
1
vote
0answers
20 views

Ajax date_query not working past the first iteration

I cant find anything on stack overflow that covers my issue, after hours of debugging and checking answers to similar questions but not quite the same scope, I cannot figure out the problem. ...
0
votes
0answers
11 views

Pass JavaScript value to PHP [duplicate]

How to step JavaScript value to PHP? The value (passValue) Or the value you have on the "on " or "off " button for here $testup = (passValue); Sorry bad English <button id="toggle" name="...
0
votes
0answers
19 views

Ajax Pagination link go to /wp-admin/admin-ajax.php/page/3 in second click event

I create a ajax pagination for twentyfifteen child theme. That pagination works fine in first click ( in case of http://example.loc/page/23 ) , but in second click it redirect me to wp-admin/admin-...
-1
votes
0answers
20 views

Get real-time button value and send to postmeta database

How do I get button value and send to postmeta database? When you click the button. Have to update the file of the plugin testok: WP-content/plugins/testok/file-update-button.php It has a function in ...
0
votes
0answers
20 views

How to update cart total after AJAX success

I am making a customized shopping cart. The Ajax code is updating record correctly. However, I am unable to update/refresh the cart total to reflect the changes made by the user until reloads the page....
0
votes
0answers
11 views

How do I append options to a select box in the customiser from an API call?

I'm working on a WordPress theme and I've added a select box to allow users to select a font for their site. I figured I'd use the Google Fonts API to grab the list of fonts rather than add all 900-...
0
votes
0answers
11 views

Wordpress Heartbeat API cannot parse data

I had a working heartbeat connection that would update a user's personal (custom) options that I have created. The heartbeat would change from their frontend dashboard to the screen that reflects ...
0
votes
1answer
16 views

Filtering custom posts by using checkboxes for taxonomy in an ajax loop always gives server 500 error

I have been working on this for hours and can find no solution. I have a website that uses a custom post type named 'Brands', which has a taxonomy named 'brand-categories'. At my client's request, I ...
0
votes
0answers
17 views

AJAX to add to cart multiple products woocommerce

I found some AJAX on here to add a product to cart through WC through a button click, and I am trying to modify it to be able to add multiple products with the single click. I am not super familiar ...
0
votes
0answers
22 views

Does wp_verify_nonce check ajax form referrer url?

I have a form "accept request" that is displayed conditionally when the accepter clicks on a unique link that was sent via email from the sender. ?> <form id ="accept" action="<?php echo ...
0
votes
0answers
14 views

Frond-end mini-framework for handling wp ajax

The question is non-specific. I have been doing lots of custom triggers to handle ajax and its responses from WP core. Is there perhaps some lightweight framework that could facilitate that? I would ...
0
votes
0answers
12 views

Metabox - update Post - save duplicated rows to database

I have created a custom_post_type with a Metabox where i can duplicate rows / items with jquery and i can sortable them. Now i want when i save the post, that the content (input fields) are saved. I ...
2
votes
1answer
59 views

admin-ajax.php HTTP400: BAD REQUEST - The request could not be processed by the server due to invalid syntax

Update 1: Based on suggestions from Rup and Jacob, I changed the data of the ajax request to this (including the entire function and not just the ajax request this time): //updated code with ...
0
votes
0answers
11 views

wordpress upload image and set as featured

I would need your help since I'm getting "crazy" as I can't figure out how to do this. Basically I have an ajax call that sends an URL and name to PHP function that uploads the file. It's supposed to ...
0
votes
0answers
60 views

Not getting ajax success response on insert/update row to database

I am not getting success response after inserting/updating record to the database. Instead ajax returning error: function(response) with Something went wrong! message. $this->gs_db is the ...
0
votes
1answer
19 views

How to add Ajax to this Pagination i made?

This is my functions file add_action( 'wp_ajax_homekong_pagination', 'homekong_pagination' ); add_action( 'wp_ajax_nopriv_homekong_pagination', 'homekong_pagination' ); function homekong_pagination($...
0
votes
0answers
42 views

Submit form for loop of products of the term with AJAX

I am developing a group shopping cart that allows group user to order from the group page. I have a product term page where user can buy all products at one time. In fact, they must have to buy all ...
0
votes
1answer
21 views

Get response for check_ajax_referer

I want to show the notice to the user if the nonce check fails using check_ajax_referer. However, the function dies itself if fails. So I just wonder that if I die using wp_die() manually will that ...
0
votes
0answers
29 views

400 Bad request while submitting form using AJAX

I am poor in AJAX and trying to submit the form and insert the record to the custom table since a couple of days but not getting it to work. I am getting 400 Bad request error on console. Please have ...
0
votes
0answers
11 views

How to progressively update a plugin admin div using ajax?

Thanks to this seven-year-old tutorial from Pippin Williamson, I have just learned how to live-load content in to an admin-side plugin page, using ajax. My plugin sets up a management page (Tools) ...
1
vote
0answers
27 views

How to get original custom taxonomy slug after the slug has been rewritten?

I'm writing ajax handling for a theme. I'm trying to get term and taxonomy slugs from a link I click. The link is being passed with jQuery to PHP for further processing. Let's say my custom taxonomy ...
1
vote
1answer
18 views

How to insert a record by clicking on the link using AJAX

I am developing a plugin for WordPress. Looking for a solution I want to insert record (it may be any CRUD operation) when the user click on the link order-button I am very much new to Ajax so ...
0
votes
0answers
15 views

Adding user using admin ajax by a user with custom role

I have a form in which user A with a custom role is able to invite other users. Javascript which handles that looks like this: sendNotificationEmail(newUserId) { newUserId = parseInt(newUserId)...
1
vote
0answers
23 views

How can I use cached images in an AJAX response?

WP_AJAX includes no-cache headers with its responses. I'm using Ajax to fetch part of a shopping cart, which includes little image thumbnails. On each Ajax request, these are replaced and we can see ...
0
votes
0answers
18 views

How to replace wp_ajax_add_tag() error notice on create_term?

I am writing a plugin which uses natural language processing and knowledge graph technology to determine the true entity type of terms added to WordPress, with the purpose of tidying up taxonomies. ...
0
votes
2answers
30 views

use with class file into wp_ajax hook

I'm trying to use a class from another file within a wp_ajax hook And the call returns a 500 status code I added the class with incloud (), I tried to put the whole class inside the function and it ...
0
votes
2answers
48 views

Help me with my first very basic plugin

I am trying to create my first worpress plugin! Actually, the idea is when i click on the button, an ajax request is sent toward php file (ajax-process.php ), it contains a very basic code to pull ...
0
votes
0answers
13 views

Manually Display a Banner on Sidebar

Is it possible to manually display an image or banner via the dashboard? For example, a widget with a an option to press a button and immediately display a banner on the homepage sidebar? We are ...
0
votes
1answer
13 views

Hook after all metadata are set is triggering several time

I need to trigger a function everytime the user save the post manually (so only thanks to the "Update button"). Here's what I have : add_action( 'save_post', 'my_save_post_function', 10, 3 ); ...
0
votes
1answer
10 views

WordPress custom post type post item data - show/fetch only on click with Javascript dynamically?

I have a question. Hopefully, I will be able to explain what I am trying to do here. I have created a custom post type "Feeds" and published 10 post types inside that CP. Now, usually, I would just ...
0
votes
1answer
17 views

Ajax Comment Upvotes - Votes don't always register

I'm trying to create a simple ajax-based comment upvoting system for Wordpress. I've managed to build most of it, but now it seems that most of the time the upvotes don't register. They do register ...
0
votes
1answer
23 views

How can I run two AJAX requests simultaneously in WordPress?

Kinda stuck here working with AJAX and trying to show posts based on user interaction. Right now I have it working where user makes a category dropdown selection and the posts load accordingly. What ...
1
vote
0answers
41 views

Refresh Taxonomies

When saving/updating a custom post type in the Admin Panel I'm hooking into save_post_{$post->post_type} and adding custom taxonomy terms from a linked post using wp_set_object_terms. The terms are ...
0
votes
1answer
16 views

How do I get rid of my inclusion race-condition on wp_enqueue_script

I'm trying not to be a lazy dev. Thus I want to only include my js files where they are needed. As the js is needed everywhere where my shortcode is used I tried to do what was answered here. i.e.: ...
0
votes
0answers
30 views

get a bad request 400 on my ajax-admin.php file

I've been working on ajax lately. The tutorials you find on the net are all very similar and quite easy to implement. But I always get a bad request 400 on my ajax-admin.php file. also ...
0
votes
1answer
30 views

Get posts by category via ajax

In my page-members.php I output my list of categories <?php $args = array( 'orderby' => 'slug' ); $categories = get_categories($args); foreach ($categories as $category) ...
0
votes
0answers
13 views

jQuery Validation plugin with AJAX and PHP Superglobals strange behavior

I wrote a HTML form in a WordPress template and I want to validate it with jQuery Validation plugin but I have problem with AJAX validation, this is an extraction of what I wrote: add_action( '...
0
votes
0answers
131 views

Test WordPress api with postman

I have some API endpoints. For example: add_action('rest_api_init', function () { register_rest_route(MY_APP_NAMESPACE, '/init', array( 'methods' => 'GET', 'callback' => ...
0
votes
0answers
16 views

check_ajax_reffer not working when logged

When I'm logged, the code works perfect, but if no logged, check_ajax_reffer fails. First, pass ajax_url and nonce's': wp_localize_script( $this->plugin_name, 'ajax_object', array( '...
0
votes
0answers
22 views

How to make a live search table in admin plugin panel in Wordpress

I want to create a live search for a database that shows results in a HTML table in my plugin admin page. This is my code: $connection = mysqli_connect('localhost', 'root', '', 'wordpresssite') ...
0
votes
1answer
39 views

How to use AJAX to call php page with parameter

I am using bit calculations so that I want to show the calculated value through php file so that I am trying to implement AJAX code but that URL not loading php file .., any suggestion please..? ...
0
votes
0answers
17 views

WP AJAX and email

I am creating a subscribe-plugin and wanting to make data through an AJAX. here is a JS code: <script> jQuery(document).ready(function($) { $( 'button.subscribe' ).click(function() {...
0
votes
1answer
28 views

AJAX update fails for public/non-admin users

I've built a function which, depending on the submitted option in a <select> input, generates a new data table (TablePress plugin) and inserts it into the page via AJAX. The function works ...