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

Can't load search results with ajax

I'm trying to load search results on my page without reloading. I tried multiple approaches already, but I still can't make it work, despite using someone else's confirmed solution. Please find the ...
0
votes
0answers
33 views

woocommerce REST api on the website's front-end

I want to use AJAX for product listing (with "show more" functionality), AJAX based search etc. on the front-end of a Wordpress/Woocommerce website. It seems like a simplest approach here ...
0
votes
0answers
9 views

jQuery - On 'removed_from_cart' event to hide Proceed to Cart Button

I have a custom mini-cart running on mobile which so far runs great. The issue I am having is that when the user removes the last product from the cart and it empties, the Proceed to Cart button ...
0
votes
0answers
18 views

Help with creating a blog

I am trying to create a blog, MemoriesOf.website, where users can share their memories of something, someone, some event, etc, with other users. There will be a widget with a dropdown, a text box, a ...
0
votes
0answers
15 views

Check is cart has products with Javascript on Remove Product

So apologies in advance for not providing any code, but its because I can't seem to find any documentation on this. Is anyone aware of any means of checking the cart for products triggered by ...
0
votes
1answer
14 views

How to return a record from a custom table by sending an AJAX request

I am trying to return a record from a custom table. On the client side, I am sending an AJAX request. <script> var eventId; var xmlhttp; var xmlhttp = new XMLHttpRequest; ...
5
votes
5answers
37k views

WordPress AJAX File Upload - FrontEnd

So I have been reading through every WordPress front-end AJAX file upload tutorial I can fine. Nothing is working for me at the moment. The one that makes the most sense to me is this one: http://...
0
votes
1answer
21 views

Ajax filter - show all results that contain at least one filter

For a project I use Timber (TWIG) with WordPress. I'm trying to implement ajax filter with tags on a video template. But it doesn't work like I would like. For the moment my system is too strict. ...
0
votes
1answer
641 views

Order & Orderby clause not working with custom query

I'm having an issue with the order of search results loaded via AJAX, it never matches the order of the same query on the search results page. The AJAX response WP_Query instance uses the following ...
0
votes
0answers
16 views

How to submit the settings api data by ajax on theme options page

Instead of reloading i need to submit the data by ajax. it is because theme options having customized tab sections and all the fields are in array in a single field of settings api. //Displaying and ...
0
votes
1answer
43 views

Conditional Fields depending on checkboxes

I'm currently trying the following (simplified objects): I have a bunch of "objects", which are cities. Each city has a relating country (even though I'm not sure how to implement this relation, yet),...
0
votes
1answer
701 views

How can i get the same ajax result using WP REST API instead of admin-ajax?

I have been told that admin-ajax is outdated now and it's better to use REST API instead but I was wondering how can I get the same result of this code which generates a button with a link based on ...
0
votes
1answer
13 views

Wordpress 403 error on form submission with Ajax

I have a wordpress multisite set up, and in my sub-site (called "team" site) I have buddypress. There is an activity stream, but I cannot post updates to the activity because there is a 403 ...
1
vote
1answer
599 views

class click counter save number

When the user clicks class count the counter should work: <div class="pop-btn" class="counter"><a href="https://www.example.com">Know More</a></div> <div class="count">&...
0
votes
1answer
16 views

Why, if a function accepts arguments, it fails on ajax calls?

I am trying to write a WP function to work with both ajax and direct calls, something like this: PHP function some_function($var){ $var = !empty($var) ? $var : $_POST['var']; echo $var; ...
0
votes
1answer
3k views

How to inject data content from external json into a modal, using UIkit?

Please point me to the right direction. On a page I have a number of products displayed. The data comes from an external json, which is called via jquery / ajax, and then the data is displayed by a ...
0
votes
0answers
8 views

Auto update frontend content

I have a custom field or the content inside a div that I must update automatically without user interference, for example I put a YouTube <iframe> with a live stream and then I have to put ...
0
votes
1answer
52 views

How can I get my Wordpress plugin to receive data and relay it in an ajax/php request to a remote server that requires authentication?

I have written a Wordpress plugin which places several buttons inside a metabox on the post-edit page. I'd go to example.com/wp-admin/post.php?post=number1&action=edit. I want my Wordpress hook to ...
0
votes
1answer
182 views

Is there a hack for using is_page() within the function.php file?

I've created a function in my functions.php that's called when the submit_form event is fired on the front-end. Here is the code: add_action( "wp_ajax_nopriv_submit_form", "submit_my_form" ); ...
1
vote
1answer
110 views

Theme is Causing Ajax Conflicts for a plugin I cant identify it

This is a bit of a odd one, It is plugin related but sadly 1 month without a response from the Owner of the Plugin im turning to the community The Problem is that I have this plugin "Visual ...
3
votes
1answer
802 views

admin-ajax returning 400 error when request is made with Fetch API

I'm developing a plugin with an ajax handler. I first coded the ajax request setting up the XHR object. Looks like this: var data = new FormData(); data.append('post_title', 'Hola como'); data....
0
votes
0answers
17 views

error_log() not working within wp_ajax_{action} handler

I have set up debugging, and using error_log("message"); works fine everywhere I have used it so far, except within an AJAX handler. How does one log to the error handler within an AJAX ...
1
vote
2answers
1k views

How to disable controls in theme customizer?

Edit: I have rewritten the question in hopes I will get a reply from someone who knows the theme customizer. I am trying to figure out how to disable setting controls in the Wordpress theme ...
1
vote
1answer
671 views

Best place to load wp_ajax_the_ajax_hook action in plugin

I am building a shortcode plugin and I want to avoid loading unecessary code unless the shorcode is called in a page. I am having trouble with the ajax functions. It seems I need to load everything ...
0
votes
0answers
26 views

WooCommerce - how to auto-update Minicart?

I am using AJAX to autoupdate Cart in WooCommerce, and I use code from this article (as shown below): Auto update cart after quantity change and it works well for the Cart amount. However, the Mini-...
1
vote
1answer
925 views

Create onClick Event to Re-load a Widget

Hey guys I have a "add to favourites" button which, when clicked on, adds a post to a list that a user can view on the page /my-enquiry-list/. I have managed to create a widget that displays the ...
0
votes
0answers
9 views

How to update user profile field on the checkbox change?

I have created a custom profile field in BuddyPress - single checkbox that is by default unchecked. I want to display this checkbox outside user profile settings page e.g. in the theme footer or ...
1
vote
0answers
19 views

Ajax random number always the same

I have a button that when I click it should generate a random number using ajax ( It needs to be processed by PHP in real world application). This works fine except that every time the button is ...
0
votes
0answers
11 views

Can't reset tax query using ajax sorting plugin?

I have created an Ajax sorting feature that filters a custom post type "Music" and its all separated by Genres and Tags. The sorting works fine until. I deselect all options. I've tried to ...
4
votes
3answers
9k views

AJAX nonce with check_ajax_referer()

I want to use check_ajax_referer() to verify a WP_nonce field using AJAX. Here you can find my html element. <input type="hidden" name="login_nonce" value="<?= wp_create_nonce('login_nonce'); ?...
0
votes
0answers
16 views

Edit Genesis Ajax Code (GIT: Lauren Gray) to work with Custom Loops

I have been using this code from Lauren Gray: https://gist.github.com/graylaurenm/86daa4f23aa8749c0933f72133ac7106 on my Wordpress site, and it works really well for the homepage and archive loops - ...
0
votes
1answer
92 views

Frontend AJAX Media Upload returning 404

I am building a custom registration form for users where they have to upload an image of government ID. Using AJAX for submission. The handler function always returning a 404 status error, no matter ...
0
votes
1answer
2k views

Get ajaxForm response value

I have this ajaxForm: $('.simple-checkout').ajaxForm({ success: function (response) { console.log(response); alert("Success"); $('.cart-value').load(location.href); }, error: function (...
0
votes
1answer
930 views

WP_Query with AJAX returning empty array

After extensive reading about this I've hit a wall with troubleshooting, so I figured I'd ask on here. I'm building out an AJAX call that will run a WP_Query and return a series of posts that have a ...
1
vote
1answer
907 views

Audio Player not loading when the content is loaded through Ajax, MediaElement.js no applied

When I load the content using ajax it doesn't apply MediaElements.js to my audio player, so the audio isn't display. I think this is because the MediaElement.js is loaded with wp-footer(), and this ...
2
votes
1answer
661 views

Is it possible to hook AJAX to UPDATE-button?

I have a site with a custom post. When I enter that custom post in admin (edit)-page then a form is rendered. This form takes like about 2-3s to render - it's a lot of of values in it - both hidden ...
0
votes
1answer
587 views

Ajax Response Error

I am going to be mad. I wasted 4 hours due this error but I can't solve it. When I want to create a category, wordpress give this error. I deleted each file in my theme, but I can't found where is ...
3
votes
3answers
10k views

Admin Media grid view images won't load

All I did was adding this in my functions.php file: function save_nb_image() { global $wpdb; $id = $_POST['id']; $file = wp_get_attachment_url($id); if ( ...
0
votes
1answer
1k views

admin ajax is not working for non logged in users

I know that this issue has been discussed many times, but I think I tried most of the advises. This is my code: $.post('<?php echo admin_url( 'admin-ajax.php' ) ?>', {'action': '...
1
vote
1answer
18 views

Scripts not appending to <head> element in AJAX call - why?

I'm trying (and failing), to get scripts to load in the header of certain posts before the rest of the page loads. Some of my posts have embeds that require scripts to work, but my makeshift code ...
0
votes
0answers
13 views

<body <?php body_class(); ?> > won't change after Ajax loaded just the main content

I’m using Ajax to load only the main content of my website, as I have a music player and I don’t want it to stop playing while browsing website. Everything is working well, except that, as the body ...
0
votes
3answers
725 views

wp_ajax action responds with 0

I'm writing a plugin. There is a button, that triggers an ajax-request to an action I added in my plugin page: Head of my plugin PHP file: add_action('wp_ajax_update_nav_items', 'update_nav_items' )...
0
votes
1answer
1k views

How To Override A WooCommerce AJAX Function

I would like to override a WP (WooCommerce AJAX function) using add_filter. The original code is set in a WC OOP class via something like: add_action( 'wp_ajax_wc_function', array( $this, '...
0
votes
1answer
573 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
1answer
989 views

Checking for new message using AJAX and PHP. Server overload?

I wrote a script (it may not be perfect, I'm newbie) to check for new message (using ArrowChat and Buddypress) every X mins. It works good, but I'm worried will it overload my server? It's shared. ...
0
votes
1answer
730 views

Help to upload post attachments from Ajax

My problem is that I cannot upload post attachments from a frontend form. I send data through AJAX to my php files containing functions. Let me be clear: everything is working great, the post is ...
0
votes
0answers
17 views

register_block_type is not working properly

When I try to get data with ajax, the register_block_type function is not firing the callback method. register_block_type( $this->name, array( 'attributes' => $...
0
votes
2answers
3k views

Filter posts by categories ajax is showing all the posts

i'm try to filter posts by an cascade dropdown categories. But when i select an option of the cascade, he showing all the posts. How can i filter ONLY posts through the selected option? This is my ...
1
vote
0answers
19 views

How to load new text widgets and polls into the sidebar without reloading the page?

We are creating a WordPress website page for the online broadcast of the conference. The page should work so that when a site visitor opens this page, the content on this page is automatically loaded ...
0
votes
0answers
16 views

Ajax Product filter by category “no product found”

I know this is a big question but i'm struggling with this for too long without any improvements because I know very little things about coding. I'm trying to create a "simple" ajax product filter ...

1
2
3 4 5
48