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

Ajax call undefined index

I am trying to get the content of an ACF field through an Ajax call. This is my callback function: function my_ajax_request() { $id = $_POST['id']; if( have_rows('carousel_slide') ): ...
0
votes
2answers
34 views

Admin-ajax.php 404 error

im trying to submit the following form but it just wont work: HTML: <div class= "container"> <div class="row"> <div class= "col-md-10 mx-auto text-center&...
0
votes
1answer
21 views

Very weird bug: Ajax for non-admins

I am seriously stumped. For some reason, a perfectly good and simple AJAX function (which exposes the user's email address to the frontend) is working for non-admins in one installation but not ...
4
votes
1answer
1k views

jQuery and AJAX Not working with Select Form Element

I seem to be having a strange issue with jQuery and a newly-created AJAX form/function. I'm pretty new to AJAX so please bear with me. Here's the jQuery: jQuery('#wpuf_new_post_form').submit(function(...
0
votes
1answer
22 views

How can I send data to admin-ajax via JS Fetch?

I'm trying to implement filter system in my website. I decided to make it via js. I created fetch function let filters = document.querySelectorAll('.filters-item'); let pageUrl = wp.page_url; const ...
0
votes
1answer
716 views

How to filter custom post data with AJAX?

I have build a custom post_type with "Resellers" in order to enter my personal reseller items. The "Resellers" post have taxonomies like "Countries" and "Departmens". I am running into a problem: ...
0
votes
1answer
2k views

400 Bad Request when sending XHR from React.js to admin-ajax.php

I'm trying to send ajax requests from a React.js app to wordpress's admin-ajax.php. Here is a mini test plugin I wrote to test this: // plugins folder > xhrLink/xhrLink.php <?php /* Plugin ...
0
votes
0answers
14 views

Calling PHP function with AJAX

I am creating a plugin for wordpress for the backend. I when the admin press a button a js function is being called. In this js function, I am calling an API, and then I want to call a PHP with the ...
0
votes
0answers
10 views

Is there a hook that fires after an ajax call?

I'm looking for a hook that is fired before the Ajax content is returned. The reason is that I want to extend the cookies with the Secure attribute I need. Unfortunately is the plugin (woocommerce) ...
1
vote
1answer
44 views

Ajax Custom Post Filter is not filtering

I'm trying to code an ajax custom post filter but the result seems like it's not filtering, and I'm not sure where I did wrong. I'll provide the revelant code below. archive-projetos.php <div class=...
0
votes
1answer
7 views

Adding LOAD MORE on a page

So I have a blog with different pages and categories and I add each post manually and link it with the URL instead of using post grid. I only want to show 10 posts at a time and add LOAD MORE text ...
0
votes
1answer
2k views

How to submit form data in the same page in WordPress without reloading the page?

I have a custom PHP template - form. I'm trying to send this form in the same page using AJAX without reloading the page. Hide the form after submission and display the thank you message. This form is ...
0
votes
0answers
5 views

Display states according to selected country

I am trying to display state's names responsively based on what country is selected from a list (via WP database). For example, user selects Malaysia, Kuala Lumpur will be displayed without the entire ...
0
votes
1answer
23 views

Where to add my PHP codes for AJAX Jquery to work?

I am trying to display state's names responsively based on what country is selected from a list (via a library). I reckon I needed to use WP AJAX and Jquery to achieve this goal. I am totally new to ...
1
vote
0answers
33 views

how to use reCaptcha in wordpress custom login form?

I tried to create a custom login form and custom register form by ajax. I have been successful to make that and you can see my code below for custom login form. the issue is, I need to use reCaptcha ...
0
votes
1answer
26 views

WP_Query is not received in Ajax

I have a load more script in WordPress, everything is perfect on the homepage but there is a problem in the taxonomy page. So when you click on the category page, it pulls out all the articles. When ...
0
votes
1answer
896 views

Run javascript upon successfully set featured image

I'm looking into running Color Thief against the featured image whenever it is set or updated. I can't seem to find any way on how to hook into this event. Currently I'm doing what I feel is a bit ...
0
votes
1answer
699 views

How to get current_user_id from wordpress in node js?

There is a website on wordpress, in the plugins folder I have a project on Node js. In index.html (the client part, mostly js there), there is content that I have to show only to registered users. I ...
0
votes
0answers
32 views

Ajax login fails: script sets cookies, but is_user_logged_in() returns false

Summary Ajax request to a back-end plugin PHP script successfully logs in the user and sets login cookies in the browser. However, the page making the call fails to recognize those cookies, and ...
0
votes
1answer
4k views

Logic of Woocommerce Ajax add to cart code to update cart [closed]

In add-to-cart.js file of Woocommerce, when added_to_cart event is triggered, this code is executed: /** * Update cart page elements after add to cart events. */ AddToCartHandler.prototype....
1
vote
0answers
11 views

Ajax loaded form replaces form action with Ajax url

I am making a Wordpress website using WPForms to use different forms. These WPForms are loaded in a modal using an Ajax trigger on a button click. When I click a button, the ID of the button is used ...
0
votes
0answers
13 views

Dynamic Twitter card images

I'm creating some images from WP posts using HTML5 Canvas and saving them to my uploads folder. I'm then sharing them to Facebook, which works fine, but to share to Twitter I need to update the ...
1
vote
1answer
11 views

Ajax category filtering products default show all

I have code that list categories and products by category. When I click "All" it list all products, but when I go /products page it's not list all products by default and I need to click &...
1
vote
1answer
2k views

Load a page into a div with Ajax

I'm really a noob when it comes to Wordpress, right now I'm working on a theme that basically is all static, if you want to edit something you'll have to edit the .php file than rather doing it on the ...
0
votes
1answer
1k views

Ajax not working to insert, query and result data

On my site, through a form I send/register same information in database, do a SELECT/query and return it! Return the last table saved in database, just that user just entered on the form (along with ...
0
votes
3answers
2k views

load ajax using admin-ajax.php

The append result is 0, instead of a list with the title ass a link. If I check this locally (http://localhost/wordpress/wp-admin/admin-ajax.php?action=lateral_fluid), I get the titles ass a link. I ...
1
vote
0answers
7 views

Get image URL after image created from canvas and sent to WP uploads with AJAX

Hello there people my people, sorry I'm a PHP newbie and could use some help! I'm making an image from a canvas element which is being converted from BASE64 into a .PNG and sent to my WP uploads ...
0
votes
2answers
41 views

Data not insert and update through ajax and jQuery in admin page?

I made custom plugin and done crud operation, display all data in admin page, used ajax and jquery. Data successfully deleted but not inserted or updated. Data successfully pass through ajax but not ...
2
votes
1answer
2k views

how load content as pop-up using ajax

There's a way to use ajax to load the content from single.php or a custom .php like ajax-single.php like this page does it: https://yellowimages.com/all/objects/apparel-mockups/ also like them show ...
0
votes
1answer
2k views

Ajax the create and edit post form into lightbox and get results

So I have a Wordpress site I built that has custom post types and references to those post types inside others. Example: Custom Post Type 1 Custom Post Type 2 - References Type 1 on two fields Custom ...
0
votes
1answer
10 views

Adding ELSE argument to AJAX Live Search for “No results found”

Having finally being able to make an AJAX driven live search functional, I need help understanding how to add an else argument function so that when there are no posts matching the search query, the ...
0
votes
1answer
2k views

How to pass array from jQuery to PHP with AJAX in WordPress?

I have a HTML form with 2 select boxes with multiple selection. I get the selected values on form submit with jQuery and store them in 2 different arrays: $('#assign_categories_form').on('submit', ...
3
votes
1answer
1k views

How to Use JSON With AJAX?

I've defined a PHP callback function to handle the communication between server-side and client-side: function json_render_modal_body() { check_ajax_referer( THEME_PREFIX . '-modals', 'nonce' ); ...
0
votes
0answers
16 views

Why does check_ajax_referer give a 403 error on https websites?

When I write an ajax funtion on a site without SSL, check_ajax_referer works as intended. But it fails with a 403 forbidden error on a https site. I've tried a lot of times, but I just don't know why ...
0
votes
1answer
1k views

ajax multiple Values

i tryed to return multiple Values from an Ajax Call, I would Like to retun Value a and value b in two separat Variables in my Ajax function. Is it posible to do that? or could I use an Array? Or ...
1
vote
1answer
31 views

Force redirect not logged in user to (wp-login.php or wp-admin) for specific page

I am currently using a Wordpress plugin (Pagerestrict plugin which references URLS based on Page ID/Slugs)to restrict certain pages to logged in users only. This plugin works fine with standard ...
1
vote
1answer
36 views

Create a new post using rest api and save featured image using an external image url

I am trying to create a post using the rest API. Which I am able to do with a fetch request as below. OurPostData contains the title, content and URL of a featured image which is an external url ...
0
votes
1answer
24 views

How to make a fetch() POST request to wordpress rest api?

I am trying to make a POST request to rest api. But I am getting 401 Unauthorised error. Also can someone help with handling nonce in it? #OurPostData : Contains the title. fetch('https://mywebsite....
1
vote
2answers
7k views

AJAX success response is not working but it's saving my changes

I'm a beginner in jQuery-Ajax so please bear with me. My Ajax response does not seem to load but my changes are being saved. but gives me this error on admin-ajax.php "call_user_func() expects ...
0
votes
0answers
9 views

Add a functionality to quickly filter custom posts in Admin Area

I am creating a website for a doggie rescue, basically configuring the backend so they can manage dogs, volunteers, etc. The legacy system had a feature where the user could start typing into an input ...
0
votes
1answer
1k views

How to add Ajax to the default widget calendar to support next/previous months loading?

I want to customize or replace the default calendar, similar to the default widget, but with Ajax next and previous months loading. Ideally I would like to be able to do that (red dots are dates with ...
5
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
17 views

How to run [products] shortcode in AJAX with loading the product label

This question is related to this plugin https://woocommerce.com/products/woocommerce-advanced-product-labels/ that is located at woocommerce.com. My question is, I'm trying to display the woocommerce ...
0
votes
1answer
23 views

Can I make get_users() query global?

I have the following query $args = [ 'meta_key' => 'mycred_default', 'orderby' => [ 'meta_value_num' => 'DESC' ], 'order' => 'desc', 'number' => 10 ];...
3
votes
1answer
5k views

Add item to media library from blob or dataUrl

I'm trying to build a webcam snapshot recorder. It should take a picture and upload it to the WP media library via ajax / async-upload. Already managed to add a view to the media library. Recording ...
1
vote
1answer
26 views

prevent default not stopping page refresh. Passing form information to and from php with ajax in a wordpress site

I have seen a number of methods dating back to about 2011 in order to take a form and have its data posted via ajax.jquery. I have tried a couple and am just getting the page to reload despite using ...
0
votes
1answer
641 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
0answers
16 views

Do not query similar content using custom meta on Ajax WordPress

I got the relelated content from costum meta using it and it works fine but when I use Ajax it query "relation" applies it incorrectly add_action( 'wp_enqueue_scripts', '...
0
votes
1answer
79 views

Setting a JSON web token from a secondary api as a secure cookie on WordPress

UPDATE THREE Since I am getting the correct responses from my own api, can I modify the responses I am getting. In the console I see this: {readyState: 4, getResponseHeader: ƒ, getAllResponseHeaders: ...
4
votes
1answer
4k views

AJAX handler throws 400 (Bad request) - why?

I am trying to apply a "Load more posts" function to a post loop, but I am dealing with a 400 Bad request, when admin-ajax.php is referred to. The reference I used is this - https://rudrastyh.com/...

1
2 3 4 5
50