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
0 answers
29 views

Ajax 400 error when used inside a plugin

I'm really, really stuck. When I run this code I get a checkbox displayed. When I click the checkbox, the javascript is run. I get "test" in the console, followed by a 400 POST error. I can ...
user avatar
0 votes
1 answer
24 views

Ajax callback not work

My files is : synergyservice.php register_activation_hook( __FILE__, array( 'Synergy', 'plugin_activation' ) ); register_deactivation_hook( __FILE__, array( 'Synergy', 'plugin_deactivation' ) ); if ( ...
user avatar
0 votes
0 answers
29 views

Using Ajax to submit a form, and run a SQL Select query based on user input from the form

I'm creating a web form on my WordPress powered website. The form is intended to allow the user to enter a ZIP Code (aka postal code). When the user submits the form, the page should query a MySQL ...
user avatar
  • 1
0 votes
0 answers
28 views

admin-ajax.php calls fail if referrer is sent with 500

calling admin-ajax.php via jquery ajax calls were failing from my site but postman calls to the same url were successfull. After some looking at headers it seems that the referer being set is the ...
user avatar
0 votes
1 answer
15 views

Add a class to WooCommerce error message with specific text [closed]

I want to add a class to the WooCommerce error message <li> element which contains specific text. The problem is that when the page loads, this element does not exist, since it only appears when ...
user avatar
  • 101
-1 votes
0 answers
13 views

Filter posts using chekbox AJAX [closed]

When I click on this checkbox with specific value, I want my post under(with the images) to filter.
user avatar
0 votes
1 answer
15 views

Contact form 7 Hide response messages after 5 seconds

I just installed this plugin and I must say it does everything I need. I am using a custom made popup div with a CF7 inside it. I need to hide response messages (error, success message) after 5 ...
user avatar
  • 117
-1 votes
1 answer
28 views

WordPress blocking polling request when signed into Admin

I've setup a polling script in js that sends an XMLHttpRequest to the server to wp-admin/admin-ajax.php (yes, legacy, I know) at a fixed interval of x seconds. The response returned by that request ...
user avatar
  • 286
1 vote
0 answers
13 views

Is there builtin way to use protected AJAX endpoint?

Usually I declare "protected" endpoints as this. So logged in users can use this endpoint. add_action( 'wp_ajax_my_action', 'my_action_callback' ); Is there a way to make it only accessible ...
user avatar
0 votes
0 answers
14 views

Disclaimer that will show every refresh of the page

Hello I have here a code that is based on a "where you first access the page you will see the Disclaimer template" but I want it to show every time I refresh the page <?php // ...
user avatar
  • 1
0 votes
1 answer
23 views

AJAX call inside plugin class is not getting to it's response function

I've looked at a heap of other people with this same problem but I still can't find a solution. Hopefully someone can see what I've missed because I'm about to pull my hair out. My ajax call is not ...
user avatar
2 votes
1 answer
25 views

Can part of my WordPress website be headless?

Just to set the scene I have a client that has a wordpress site with a mixture of "static" pages and woocommerce shop. The product catalogue has approx "86,000" products in it. ...
user avatar
  • 21
0 votes
0 answers
47 views

AJAX function running TWICE with WordPress admin-ajax.php

I have a form submit event that calls a WordPress ajax function. The form submit event occurs only once (It is correct as expected). But the ajax function loaded TWICE (expected to occur once). Here ...
user avatar
  • 11
0 votes
0 answers
12 views

Woocommerce Variable Product Dropdown for Custom Shop Template

I'm building out a custom shop template and I'm trying to achieve something like this. Where the user can choose the product variation in the dropdown, choose quantity, and click add to cart without ...
user avatar
0 votes
0 answers
14 views

Display the same randomized query results on browser-back

I'm creating a query based on certain criteria and if the returning query yields more than a displayable amount of hits, I rand them. Which works great except if people navigate away from the query-...
user avatar
  • 21
0 votes
0 answers
12 views

Strange admin-ajax / CSS / $_SESSION issue

TLDR: I'm generating a random token on a front-end form and storing it in $_SESSION to later retrieve by the ajax script. THE ISSUE: The code retrieved by the ajax script does not match the one ...
user avatar
0 votes
1 answer
35 views

WordPress wp_localize_script nonce and ajax URL

I'm making an Ajax call in an Elementor site, and I'd like to use a nonce while doing it. Since my code is really simple, I didn't create a new JS file for it placed in Elementor's HTML widget, and I ...
user avatar
  • 3
0 votes
0 answers
30 views

wordpress mysql / wpdb ajax load more for terms help

Can anyone pls assist me with my problem. I am not asking for code, but even some guidance as to how to get this working. I have tried many ways, to get my terms to load using ajax load more and seem ...
user avatar
  • 16
0 votes
0 answers
13 views

Wordpress Select Option Load Custom Fields

I created a new post type called "Programs" and i created custom fields on Programs width Advanced Custom Fields plugin. I want to compare the Programs fields with each other on the page ...
user avatar
0 votes
0 answers
7 views

WordPress cascading dropdown selection search based on Parent Page & Child Page

How would I create a cascading dropdown select search where the first dropdown would host selected Parent Pages and the second to display the Child Pages of the selected Parent. When submit button is ...
user avatar
  • 11
0 votes
0 answers
17 views

Display WordPress search results based on the selected Sub-Category

I'm trying to create a search using dropdowns in WordPress. I've got two dropdowns, 1 - Parent Category and 1 - Sub-category. The Sub-category will show automatically based on the selected Parent ...
user avatar
  • 11
0 votes
0 answers
11 views

Deleting records with AJAX, deleting records as I search

I have made a live search engine with ajax which can search for records form the database table, and now I want to include delete functionality in the output results. For this purpose, I have made one ...
user avatar
0 votes
0 answers
24 views

JOIN filter doesn't work in WP_Query in wp-ajax calls

In order to get list of objects I make new \WP_Query request to the database using posts_join filter (JOIN with other custom table). It works fine with direct loading of PHP page. But the same code ...
user avatar
  • 111
0 votes
0 answers
14 views

Woocommerce AJAX filters option loading spiner - problem on mobile device

I've got quite weird problem. I built product filtering options, sometimes the server is slower so I wanted to add a loading spinner while you wait for the results. I only managed 50% because it works ...
user avatar
0 votes
0 answers
10 views

is there's a way to get the next page content generated by page break block with ajax call?

I'm using wordpress page break block to devide the post content, and i want to add a feature to lead the content in next separated page via ajax I already tried this code global $post, $page, $paged; ...
user avatar
0 votes
0 answers
12 views

How to make ajax load posts from the current category?

I have a function which loads in posts by click, however on category pages /category/**** when using that button it should only load posts for the same category. I can't seem to get it to work and not ...
user avatar
  • 13
0 votes
0 answers
44 views

Custom ordering fails after AJAX post filter

With the invaluable help of a fellow developer (nicknamed SallyCJ), I have managed to order custom type posts by the last 'word' of their titles (integers ranging from 358 to above 1000). I have ...
user avatar
0 votes
0 answers
19 views

Using some Loop or repeatable fucntion in AJAX and PHP to reduce repeatability

I am having a code, in which textbox border color changes, if values exist in wordpress database table. Briefly, if match1 textbox value exist in table:xrd_references, column:ref_code, then the match1 ...
user avatar
0 votes
0 answers
17 views

Updating failed. The response is not a valid JSON response. specific to my browser when I include javascript in my html

I was able to insert custom html into my gutenberg wordpress editor (hosted by bluehost) and test my code by preview with no problems. I made calls to google maps and fetch() to get a list of ...
user avatar
0 votes
0 answers
34 views

Custom WP rest api endpoint only working on non https?

I'm googling like an hour for a possible solution while im trying to create my first custom wordpress rest api endpoint. If i call the endpoint by postman it just works, but if i try with jquery, it ...
user avatar
0 votes
1 answer
324 views

Uncaught TypeError: Cannot read properties of undefined (reading 'message') [closed]

I wrote authentication for the entry and membership of wordpress. The code I wrote is ajax. not work Validation and redirect. But he gives the following error: Uncaught TypeError: Cannot read ...
user avatar
0 votes
1 answer
31 views

Sql formatting for post data within function

I'm calling a function through ajax in my site, and within the function that's being hit I'm taking the data (in this case it's a search term) and putting it into LIKE statements in sql: $...
user avatar
  • 113
0 votes
1 answer
24 views

Ajax call on new site with jupiterx theme getting 400 response [closed]

I have a new site up and running with JupiterX theme and I just added this code in my functions.php file in order to handle an ajax request: function sgtGetListings() { echo 'FILE IS WORKING NOW'; } ...
user avatar
  • 113
0 votes
0 answers
33 views

Tracking Visitor LatLng with Wordpress using JS, PHP. How to put data which was extract using JS into DB

Case: I tried to implement via js a geolocation tracker (not an IP Tracker). The code snippet is under Divi > Integration > Body Tag (Divi Page Builder). Afterwars i build via PhpMyAdmin a table ...
user avatar
0 votes
0 answers
17 views

Add ajax to plugin in admin area

I create custom plugin that to add new admin page ( payments settings) this page show all payments methodes with toggel to active and show setting button to this method or deactive it like this https:/...
user avatar
0 votes
1 answer
20 views

Wordpress action - Pass arguments into action in an AJAX call?

My theme uses a custom action which expects two arguments. I am trying to call the function in an AJAX call but because I am not passing those arguments I end up getting a 500 error. The action is ...
user avatar
  • 363
0 votes
1 answer
41 views

Load Posts on Click via Ajax into a DIV

Is it possible to load a specific amount of posts on click into a DIV via ajax? I've found a lot of tutorials, but all of them make use of the load-more- / next-page-functionality of a theme. What I ...
user avatar
0 votes
1 answer
21 views

Ajax on the Administration Side of plugin - wp_localize_script - how to pass value from JQuery to PHP function in class?

I have built a plugin and I need to use ajax in the admin and have followed the documentation here: https://codex.wordpress.org/AJAX_in_Plugins However, this is out of date and I cannot find any ...
user avatar
  • 79
0 votes
1 answer
26 views

Ajax on the Administration Side of plugin - returns 0

I have built a plugin and I need to use ajax in the admin and have followed the documentation here: https://codex.wordpress.org/AJAX_in_Plugins However, the response I keep getting is 0. I know ...
user avatar
  • 79
0 votes
1 answer
134 views

WordPress Search Ajax + Isotope + InfiniteScroll

Custom Ajax Search filter for WordPress Search I want to give a complete breakdown so you can easily analyse the problem and see that the issue is nowhere else, but the JavaScript. If you are not new ...
user avatar
0 votes
0 answers
22 views

Ajax Post Filter | Split Taxonomy Into minPrice & maxPrice

Very much hoping that somebody can help me out. Currently creating my own Ajax Post Filter, using https://rudrastyh.com/wordpress/ajax-post-filters.html as a template. Is it possible to split one ...
user avatar
0 votes
0 answers
18 views

WordPress responds to the ajax request with readyState 1, 2, 3 before responding with 4

readyState= 1 this.status= 0 readyState= 2 this.status= 200 readyState= 3 this.status= 200 readyState= 4 this.status= 200 These are the responses I get, and in the end it finally responds with 4 and ...
user avatar
0 votes
1 answer
16 views

Disabling ajax code that does a POST request that ends in a 400 error code

I have a javascript snippet that sends a POST request, but the backend no longer serves that request. Would removing that code significantly improve the website performance? The problem is that the ...
user avatar
  • 1
0 votes
0 answers
30 views

How do I make these combination select filters work when only one dropdown is set? They work in Wordpress 5.8.2 but don't in 5.8.3

I have a custom post type: 'insight'. I have 5 custom taxonomies: insight_service, insight_type, insight_month and insight_year. I'm using a form with select dropdowns dynamically filled with the ...
user avatar
0 votes
1 answer
13 views

Database entry removed on browser refresh, Ajax PHP jQuery

I have a form that updates columns in a database table on submit of a form via ajax. Everything works great, the database table columns get the information however once the browser is refreshed the ...
user avatar
0 votes
0 answers
46 views

Merge PDF files from post custom fields(ACF) into one PDF file and respond back the created PDF file, Wordpress(AJAX Request)

I am using Advanced Custom Fields plugin(free version) for attaching 3 different pdf files to a single post. After displaying a list of posts on a template, with a button click I am making an AJAX ...
user avatar
0 votes
1 answer
40 views

Is it possible to access admin-ajax.php using PHP?

This might be a weird question, but I need to access admin-ajax.php using PHP. One of my plugins creates a PDF that is displayed only in admin-ajax.php, I want to download this PDF using a piece of ...
user avatar
  • 3
0 votes
0 answers
25 views

wp_query 's' parameter does not work with WC_AJAX

Hey developers I have a problem, I created a search input to filter products by wc_ajax but when it's trying to filter the products it always shows that there is no product found here is image: and ...
user avatar
0 votes
0 answers
50 views

admin-ajax.php 400 bad request

I had created the ajax request add_action('wp_ajax_test_action', 'test_action'); it works fine until some point (Maybe i installed some plugin, but i had tried uninstall it but cant solve it) So i ...
user avatar
0 votes
0 answers
52 views

Automatically refresh div id every 15 seconds with code snippet from .php file

I want to automatically load song-history.php into the div id #song-history every 15 seconds via ajax without refreshing the actual template page in my child theme. song-history.php is just a php file ...
user avatar
  • 1

1
2 3 4 5
52