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

Use value from Ajax call in PHP function

I have a ajax script that will take a value from a select from on onchange. This works well, and with console.log I can see the correct value. My select form triggers a reload, and I see the value in ...
0
votes
1answer
33 views

Passing value from select form with Ajax not working

Im trying to pass a variable from a select form, but cant get it to work - whats the correct way to do this? Console is now giving me object error: statusText: "parsererror" Update: Changed ...
0
votes
1answer
24 views

Settings API form - submit with AJAX

I'm creating a plugin where I have a dashboard that is done with Settings API. I'm trying to save data from that form via AJAX. Form: public function agy_dashboard_page() { ?> <form id=&...
0
votes
0answers
9 views

current-menu-item not apllying with wp_nav_menu() on ajax

I'm calling the wp_nav_menu() via AJAX Example: function get_mobile_menu() { global $wpdb; wp_nav_menu( array( 'theme_location' => 'primary-menu', 'container' ...
0
votes
0answers
14 views

How do I call a value from the datase using ajax

I need to call and display a value for the users using Ajax but I'm not sure how to do it. Currently the plugin I use call it using a query that means the users must refresh thier browser every few ...
0
votes
0answers
22 views

Search live Ajax

It is necessary to reach the search entries instantly, but why can I cause such an error? This error : POST https://localhost/theme/wp-admin/admin-ajax.php 500 (Internal Server Error) Following my ...
0
votes
0answers
14 views

Sending email through Ajax without page refresh hangs on admin_ajax.php

I have this test page on a website - https://piclits.com/test-slideshow/ It displays a bunch of images/PICLITS and grabs them randomly from a folder 12 at a time into a slideshow. I want to email the ...
0
votes
0answers
15 views

WooCommerce variable product can not add to cart using ajax after updating latest version of WooCommerce

if ($passed_validation && WC()->cart->add_to_cart($product_id, $quantity, $variation_id) && 'publish' === $product_status) { In this condition WC()->cart->add_to_cart($...
0
votes
1answer
39 views

How to test nonce with AJAX - Plugin development

I built a plugin, but now on end, I am not sure whether my nonce integrated correctly, and I'm not sure how to test them. Can anyone help me test it or let me know if the nonce is integrated correctly?...
0
votes
1answer
28 views

Ajax call returning 0 in page template

I try to add custom form in my child-theme. I have been read all documentation of this issues but still return 0, this my code function.php (child-theme) function my_custom_scripts() { ...
0
votes
0answers
21 views

My Custom Post Type AJAX Query is Returning no posts - why?

When I run this query on posts_type => "posts" it works just fine. But when I add my custom post type 'post_type' => 'case-studies', I get no results. The custom post type has a custom ...
1
vote
0answers
31 views

How to store data from multiple forms using ajax and php

I have custom post loop, and for each product I have form. I'd like to store data in array for each click submit button in each product. E.x. Product A with Form and some values (price,quantity) click ...
0
votes
2answers
65 views

Wordpress admin-ajax.php 400 bad request

I try tu run wp form with ajax but console return Wordpress admin-ajax.php 400 bad request. jQuery(function ($) { $(document).ready(function () { jQuery('#...
0
votes
0answers
31 views

How to filter custom post type by multiple Taxonomies

On the project there is a filter: It should filter the custom post ty recipes. Selected items are checkboxes. So, several values for filtering can be selected at any time. But in my case, filtering ...
0
votes
0answers
57 views

Post form - AJAX won't upload featured image - Plugin development

I have a form for adding a post via AJAX and PHP. I have three fields. Text, textarea and file input field. Everything it's working, but it won't upload a featured image. When I remove the AJAX call, ...
0
votes
1answer
35 views

unable to use 'new WP_Query' in AJAX call

I'm trying to create category filter for posts. I usually work with get_posts function but this time I need to keep pagination, that's why I'm trying to use new WP_Query. I have successfully created ...
0
votes
1answer
67 views

Posts form with AJAX request - Plugin development

Trying to create a form with AJAX call on the Frontend where the users can submit a post. There is one text field, one textarea, and one file field. Here is the form: public function pp_html_template()...
0
votes
0answers
28 views

javascript onClick update user_meta from jquery.ajax

The idea is to add two values and the total of the sum save it or update it in user_meta with jquery.ajax. This is the code, but it gives me an error in the console Uncaught ReferenceError: 'total' is ...
0
votes
0answers
26 views

Is there a public ajax endpoint?

I am making ajax requests and everything seems to go to admin-ajax.php. I am writing a public facing plugin and it seems strange that a user would make a request to anything with the word admin in it. ...
0
votes
0answers
34 views

How to ignore WP_ERROR caused by "get_the_excerpt" method in an AJAX call?

function get_post_data(){ $post_id = $_POST['post_id']; ... $data['title'] = get_the_title( $post_id ); ... $data['excerpt'] = get_the_excerpt( $post_id ); ... ...
1
vote
0answers
22 views

Using a custom plugin to capture input data via Ajax and PHP

I'm very new to WordPress, so please excuse my possible lack of understanding. I'm super comfortable with good old vanilla HTML/JS/CSS, and transitioning my hard coded site into WP. My old site had ...
0
votes
0answers
29 views

Using Ajax and WP_Query to load more posts on category page fails

I'm using the code below to load more articles on click beneath the 10 posts that are already loaded on page load. It works perfectly on my front page, but when I use it on my category page, it will ...
0
votes
0answers
15 views

Using AJAX to filter posts without refreshing page

I am trying to create a filter to display posts by language (for each category, I have made subcategories to categorise posts by language), however, I cannot seem to get it to work. I have entered the ...
0
votes
1answer
25 views

WordPress Ajax Call inserting data but success response false

I'm trying to post data to a custom table via Ajax call and it works fine (rows are being inserted in MySQL custom table) but I'm not getting success response true in console.log. Here is my code. PHP ...
0
votes
0answers
37 views

Issues calling rest api from a custom plugin javascript

So, I have a custom plugin I'm working on for a WordPress site. I need to make an ajax call when a button is clicked. But when I make the call, nothing happens. So far I got this: I've already ...
1
vote
0answers
27 views

If I leave out the wp_die() in the testiframe function I get the '0' appended to my output. If I put it in, the page w/ iframe linked to it crashes

add_action('wp_ajax_ajtestiframe','testiframe'); <?php function testiframe() { ?> <head> <style> .aatest1 {color:red;} </style> </head> <span ...
0
votes
1answer
18 views

Not saving custom taxonomy while using ajax

im doing a custom form to save a CPT with a custom taxonomy using ajax, everything saves fine but the custom taxonomy doesn't I tried my code to save the CPT using only php and the taxonomy save ...
0
votes
0answers
16 views

What is the hook for admin ajax post comment

Other hooks like wp_insert_comment , comment_post , comment_post_redirect , all of them works when comment is posted from comment form. however , I did not find any hook which will trigger when the ...
0
votes
0answers
17 views

WooCommerce event works in jQuery but not in JavaScript

I'm using WooCommerce hook added_to_cart which works perfectly in jQuery, but doesn't work in vanilla Javascript. Both functions are running on document loaded. Here is my code reference: JavaScript ...
0
votes
1answer
52 views

Wordpress POST AJAX call, var_dump($_POST) NULL and AJAX response empty when inside ob_start

i have a nav tabs when i click on a tab, i want it to return a specific type of posts, here's the code html one of the tabs: <ul id="menu-menu-secondaire-blog" class="nav nav-tabs&...
0
votes
0answers
19 views

404 Page Not Found - only when not logged in

I have read about this problem quite a lot and tried all the suggested solutions such as disabling plugins or re-saving permalink settings but I still have the issue that one section of my website ...
0
votes
1answer
31 views

Woocommerce with Lazy Load php and ajax

I want the photos to load as I scroll down with the window scroll, but I get an error in the ajax request, I wonder what is the error that I can't see? The error I get is below POST http://localhost/...
1
vote
1answer
37 views

Code run fast on a cronjob but slow with a do_action or ajax call

I am creating several posts from a csv, when I execute the code using a cronjob the operation lasts about 7 minutes, but if I use the code directly in a template, or make a call to do_action or ...
0
votes
0answers
37 views

Can I use application/json content type in Wordpress

I was using application/x-www-form-urlencoded and it was working all ok then I changed the content type to application/json and it is returning a 400 Bad Request error. Is it that WordPress dosn't ...
1
vote
1answer
40 views

Ajax for woocommerce product filter not working any suggestions please? [closed]

When I try to change my dropdown list, current whole empty page shows up instead of products. Can anybody tell me what I am doing wrong? <form action="" method="POST" id="...
0
votes
0answers
15 views

Allow non logged-in users to upload image to the media gallery?

I'm trying to get uploads to work on the front-end for a client. Currently, they work exactly as I need them to when I'm logged in, but for anyone that isn't it times out. It seems like it should be ...
0
votes
1answer
109 views

Change URL without reload Ajax

Can I change pages with Ajax + Wordpress without reloading? Only articles related to dynamic post display or AJAX pagination are available on the web. Where can I find out about the use of AJAX in '...
2
votes
1answer
44 views

WordPress Sending data to Ajax with select option

I'm pulling my data from the database and then I want to load the pulled data with ajax but I am not able to do so. Following is my code. jQuery code: jQuery(document).ready(function () { jQuery('#...
0
votes
1answer
20 views

How to deal with too many $_POST variable conditions from ajax request at backend? [closed]

At work, we write a PHP application. I'm only a junior, but I'm dissatisfied with the problem of processing AJAX calls. Each of AJAX request is directed to the single appdata.php script. At appdata....
0
votes
0answers
21 views

wp_query with pagination via ajax in WordPress

I want to show custom posts by WP_Query with Pagination in WordPress. When I click the next button, then reload the page & go to admin-ajax.php. But Posts are load well, the main problem is ...
0
votes
1answer
21 views

Error datatable whit ajax

nice to greet you. I am trying to integrate datatable js to my plugins but it gives me a 404 error on the end point request I am following this tutorial. https://mogul.nz/2020/10/how-to-wordpress-...
0
votes
0answers
31 views

Load more posts using AJAX based on posts inside WP_Query

So this is something that I have been battling with for some time now and I can't figure out how to "Load More" posts using AJAX with a combined query. Is it possible to AJAX Load more with ...
0
votes
0answers
19 views

ACF — AJAX populate Gallery field with a Post select

I have a post type with two fields: a Post select and a Gallery. On Post select change, I’m getting the image IDs from several fields in that post and attempting to attach them to the Gallery field. I’...
0
votes
0answers
15 views

400 bad request in admin-ajax.php file

(function ($) { $(document).ready(function () { $(document).on('submit', '[data-js-form="filter"]', function (e) { e.preventDefault(); var data = $(this)....
0
votes
0answers
14 views

Load more posts on click

In my search.php I put this code <?php $args = [ 'orderby' => 'relevance', 'order' => 'DESC', 's' =&...
0
votes
0answers
18 views

Hide autocomplete and fetching users when adding existing users WP multisite

Normally in the Add User section in a WP multisite, there is a section that you can add an existing user of the network to a subsite. When typing to add an existing user the autocomplete function ...
0
votes
1answer
24 views

Set cors header for ajax requests

I am trying to use wp-ajax inside another sub-domain, but I am getting a CORS error. To solve this I used add_action with the send_headers hook: function cors_header () { header('Access-Control-...
0
votes
0answers
24 views

Validate nonce with post ID in AJAX

I'm trying to create a nonce in an AJAX form where I can pass in a post ID. Then, validate it of course. I want to confirm that if the action is intended, but also the post ID so someone cannot just ...
0
votes
1answer
39 views

Why isn't the 'no results' being shown when a query returns no results?

I've been following this tutorial for a simple AJAX filter search within wordpress: https://itsmereal.com/simple-ajax-filter-search-for-wordpress/?unapproved=3915&moderation-hash=...
0
votes
1answer
36 views

Multiple AJAX handler functions conflict in functions.php

I have two different AJAX load more functions in my website. One for my archive page, the second for the taxonomy page. The issue is, there is a conflict when both AJAX handler functions are in my ...

1
2 3 4 5
51