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
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
1k views

wp_create_nonce() in REST API makes user->ID zero

I have trouble with wp_create_nonce() and wp_verify_nonce(). The root of my problem is both the way nonces are created and the place where I generate nonces. Looking at the codes of wp_create_nonce()...
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 ...
1
vote
1answer
26 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 ...
1
vote
1answer
7k views

Dynamic dependent Dropdown lists for categories, sub-categories and posts

I'm using WordPress 3.5. I need a way to implement a code or plugin to allow users to navigate through posts using dependent(chained) dropdown lists. In other words I would like 3 dropdown menus to ...
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 ...
4
votes
1answer
10k views

wp_query->max_num_pages always returns 0 on custom post type

Hi there I am developing a theme where I have to load some posts with ajax, in my index page everything works properly, the problem is when I need to use it on custom post type, I pass the values for ...
0
votes
0answers
53 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(); ...
2
votes
1answer
2k views

WooCommerce add_to_cart url not working [closed]

I created a custom button to add products to cart and I'm using this link: http://signaturecarbone.s23528.liner7.atester.fr/panier?add_to_cart=91&product_id=91&variation_id=93&...
0
votes
0answers
24 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
27 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
2answers
96 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
59 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
1answer
1k views

How to echo a PHP code into WooCommerce variation product?

I have a little complex to explain the problem which I hope someone can understand and help me with. I have set custom fields on WooCommerce which I use to enter a specific code for each product (...
0
votes
1answer
1k views

Ajax Pagination on Ajax filter

Following this great tutorial I've implemented Ajax pagination with scrolling: https://www.billerickson.net/infinite-scroll-in-wordpress/. Now, I've added a second Ajax call to filter the posts by ...
0
votes
0answers
12 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 ...
4
votes
2answers
10k views

admin-ajax.php returns 0. How do I debug it and fix it?

Trying to use admin-ajax.php to upload image from front-end form. I'm keep getting 0 with below code I have and not sure how to debug this or where it goes wrong. I have HTML input file <input ...
0
votes
0answers
786 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:...
1
vote
1answer
2k views

How to Dynamically Load Content Into Body of Bootstrap Modal Window?

I found this answer on Stack Overflow, answer this exact question. I've modified it slightly, because I'm using a button and not an anchor: jQuery( ".modal" ).on( "show.bs.modal", function ( e ) { ...
0
votes
1answer
18 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
202 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
34 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
1answer
484 views

Admin Ajax returns “0 200 OK server error..” in Multi-site sub-site

I'm aware admin-ajax.php is intended to return '0' if there's no action set. My issue seems to be that it's returning an error after the '0'. Accessing the file mu.site.com/wp-admin/admn-ajax.php ...
1
vote
1answer
2k views

Variable Products Being Added to Cart with AJAX on Shop and Category Pages

By default, Woocommerce ajax add to cart functionality is only supposed to apply to simple products on archive, shop, category pages, etc.. But for some reason it is also adding variable products to ...
0
votes
0answers
29 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
1answer
151 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
0answers
16 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
15 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
16 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
24 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....
3
votes
4answers
26k views

ajax live search for post title

i m creating a AJAX live search to filter posts title in my wordpress theme. As i write something in input it show all the post in result, Not filtering it to get custom post.. How to search live ...
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
83 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
12 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
55 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
28 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
35 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
1answer
33 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 ...
1
vote
0answers
12 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
2answers
197 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
216 views

Woocommerce variable products are being added to the card on the homepage (ajax)

Variable products only on the homepage are being added to the card instead of navigating to the product page when i press the select options button. I am using tyche theme By default, Woocommerce ...
0
votes
1answer
98 views

AJAX numerical pagination problem in TwentyFifteen-child theme

I want to create an AJAX numeric pagination. And found code in a website. And it works perfectly at first click event, but on the second click it doesn't. If I click in pagination page 4, it works ...
1
vote
1answer
39 views

Put CSS inside a PHP file and include it the right way

I want to put CSS inside a PHP file, because with that I can use 'conditional CSS', depending on the value of a customizer control. My idea is to create a new php file, somewhere in my theme ...
2
votes
1answer
2k views

Basic ajax call in WordPress

My aim is to create the most simple ajax call in WordPress, but I can't get my head around how it works. JS File: jQuery("#votepostform").submit(function() { var url = "file.php"; // php script ...
0
votes
1answer
493 views

Get custom fields when hover link of post

I have custom page and get some links of post if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); ?> <li><a href="<?php ...
0
votes
0answers
35 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
320 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
31 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
28 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
3 4
5
6 7
48