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
34 views

Adding a second product at checkout via AJAX - Can I just manipulate the code, or do I have to copy it?

I have a checkbox that once checked, is checked by AJAX and a product is added to the cart. Do I need to duplicate the entire code or is there a cleaner way of adding a secondary product that does ...
0
votes
0answers
205 views

PHP - AJAX - field group array POST value always says undefined index

I have a group of two clonable fields name and email. So when user clones, they will have a set of name and email fields. Note: These fields are newly added to my code and AJAX was working fine with ...
0
votes
1answer
217 views

get all products of one category

i use this function to get all products of one category in ajax request function get_products() { $cat_id = $_POST['category']; $args = array( 'post_type' => 'product', '...
0
votes
2answers
40 views

ajax request in wordpress

i create ajax request in functions.php function my_enqueue() { wp_enqueue_script( 'ajax-script', get_template_directory_uri() . '/js/script.js', array('jquery') ); wp_localize_script( 'ajax-...
0
votes
0answers
11 views

contact form ajax error response

I have this code that is supposed to stop the form if the nonce isn't correct. I'm not able to test my contact form, I will get the 'Errore' response and the emails are not sended. Is there a fix to ...
1
vote
1answer
26 views

wordpress and add actions to button by coding

I create my action in functions.php add_action('wp_ajax_myfilter', 'misha_filter_function'); // wp_ajax_{ACTION HERE} function misha_filter_function() { echo "my button action"; } How can i ...
0
votes
0answers
20 views

Can't GET Variable from AJAX URL

Trying to $_GET two variable from a URL generated by a HTML5 Construct 2 embedded game. http://wordpressexample.com/savescores.php?name=NAME_HERE&score=1337 Using <?php /** Sets up the ...
0
votes
0answers
131 views

WP AJAX Request Not Working

I'm trying to run wp_insert_attachment and update_user_meta using AJAX request but it doesn't work. js file import $ from "jquery"; class PersonalInfoUpdate { constructor() { this.events(); ...
1
vote
1answer
27 views

Two loops, one AJAX loop, exclude posts in first loop from second loop, loops are in different files

I have two loops that display posts: the 'default' loop (in home.php), which displays five posts. At the bottom of the page I have a button, that invokes an AJAX call, which calls a second loop and ...
0
votes
0answers
40 views

Post form data and localstorage data in Ajax request

I am creating a quote form. it works with basic info (name, email etc) now I would like to incorporate data that is stored in my localstorage (a bit like a shopping cart) The structure looks like ...
0
votes
0answers
36 views

400 Bad Request - Post to admin-ajax.php

Any ideas as to why I'm getting a 400 Bad Request from this? JS $(document).on('keyup', '#typeahead_input', function() { let typeahead_query = $('#typeahead_input').val(); let post_data = { ...
1
vote
1answer
99 views

admin-ajax return error 400 for Chrome/Edge but not Firefox

I have a bug with an Ajax request but it works on Firefox. You can test it clicking here For Edge/Chrome I got a 400 error. In Edge I got this error : HTTP400: INCORRECT REQUEST - the request ...
0
votes
0answers
18 views

Display issue when changing item in woocommerce_ajax_add_order_item_meta handler

I need to deal with automated corrections when the shop-owner adds items to an order manually. This works fine in as far as the items do get updated, but this update is not shown immediately. In ...
0
votes
1answer
16 views

Passing values via an Ajax querystring

I have an iframe (I'm embedding YouTube videos) in my post.php template. What I need to happen is that everytime the iframe is mouseover'd, a value is passed via Ajax to a custom field in order store ...
1
vote
2answers
153 views

Create Proper WordPress Ajax Request in JavaScript, NOT jQuery

Okay, so I programmed the following ajax code for my plugin, and I'm wondering why it's not working: JavaScript: function myFunction() { let dataContent = "hello"; let myData = { // Nonce ...
1
vote
1answer
2k views

Woocommerce add to cart quantity buttons with AJAX

I have on every page (product pages, single product page) plus and minus buttons next to the quantity to add up, next to the button a add to cart icon in AJAX. I can't figure out 2 problems: Issue 1:...
0
votes
1answer
20 views

Ajax Multi Response Problem

When I was trying to get multi-response from php shortcode function, I had the strange result with its Json output. In my php, $result['success']=false; $result['string']='You have not uploaded ...
0
votes
0answers
48 views

Using vue-router to navigate wordpress posts and pages

It's very cool to use vue.js and wordpress togheter. I'm developing my first vue powered custom theme and I need some help. What I would ask is if I can use the vue-router to navigate a wordpress ...
0
votes
0answers
398 views

Submit remote form to wordpress REST API and save data to custom post type

I will use the wordperss REST API to submit a form that is part of SPA webapp made using vue. I have registered a custom post type to hold the submitted data, specifically I want to register some ...
0
votes
0answers
32 views

Pass values to ajax

I need to create notification when user's added quantity is reaching item's quantity. This is working function without ajax. add_action( 'woocommerce_single_product_summary', '...
0
votes
0answers
19 views

Save draft button not saving blog post

I have spent ages trying to figure this out and I am baffled! Hoping to get some help. This is in relation to my wordpress.com blog http://befreewithlee.com/. My save draft button on my blog posts ...
0
votes
0answers
20 views

Ajax WordPress live predictive search and category filter

I'm trying to add a live search functionality to my site that will fetch and display custom posts on a separate div container without page refresh. Please help! Also, is there a way to display(filter) ...
0
votes
1answer
21 views

rest_no_route custom route

I get a rest_no_route error if I try to use a custom endpoint I've created. Is there any solution? I'm creating my theme routes inside a plugin class, but I don't think this is a problem. I'm using ...
0
votes
1answer
366 views

Wordpress REST API register_rest_route give a 500 error

I want to create a class to register my custom theme rest routes. After I wrote this piece of code I've noticed that the rest api will give a 500 error and axios isn't able to get the data. I want to ...
0
votes
1answer
25 views

Unable to call woocommerce hook in my custom php file

It is not a plugin, it is just a simple file call on ajax. My Js code $('.pkg-btn').click(function(){ var this_id = $(this).parent().attr('id'); var url = templateUrl+'/tw-add-to-cart-ajax....
1
vote
0answers
15 views

wordpress, search form using ajax

I am completely new to WordPress and my maximum is to create a plug-in with a function that displays "hello, I work." I have a search form by first and last name, and a working api written by me on ...
1
vote
0answers
158 views

Admin Notification after save_post, when ajax saving in gutenberg

How can I display an admin notification? I want to do some actions on the save_post_post action and want to inform the admin about the success and details about the action after that. I tried so far:...
0
votes
0answers
13 views

Check if username or email taken from REST API AJAX & WordPress

Is it possible to check if it is taken username or email in registration? I have a popup with register and login form, but as a result, I don't have back errors to display on the front of the site. ...
2
votes
1answer
59 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
34 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
39 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
13 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
39 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
55 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
519 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
65 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
29 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 ...
0
votes
0answers
90 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
64 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
1k 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
381 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
26 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
56 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
175 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
271 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 ...
1
vote
0answers
316 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
75 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
527 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,...
0
votes
2answers
60 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
584 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 ...

1 2 3
4
5
49