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

Remove "?category=" in the URL wordpress ajax filter work for category

I need to remove "?category=" in the URL? We are building a category filter through ajax and we need to remove "?category=" in the URL. Below is our URL https://exelgroupstg....
  • 1
0 votes
1 answer
13 views

wp_enqueue_scripts with JS script as a string

isn't there any way to load a script through wp_enqueue_scripts and have my script instead of in a file, in a variable declared earlier? Something like: add_action('wp_enqueue_scripts', '...
  • 123
0 votes
0 answers
12 views

Refresh wp_query with no changes

I have a page that contains a template part (for a map) and in that is a wp_query that pulls in the post__in parameter from an array of ID's from the Wordpress Favourites plugin. On the same page I am ...
0 votes
0 answers
14 views

how reduce fetch/XHR response time

i using this code for ajax requset front code: function ajax_request() { jQuery(document).ready(function () { $.ajax({ url: ajaxurl, type: 'POST', ...
0 votes
0 answers
24 views

Wordpress error

Hell, I have an error: Fatal error: Uncaught Error: Call to undefined function apply_filters() in /home4/smakolyk/public_html/pcwordpress/wp-content/plugins/woocommerce/includes/admin/importers/...
0 votes
0 answers
19 views

Running js in html code with same content

Before asking this question, I read a lot of articles on the site but I couldn't find how to do it. My html body also has sections with the same div names, inside these sections is the section I run ...
0 votes
1 answer
14 views

PHPUnit Ajax Serialization of 'Closure' is not allowed

Trying to set up a simple AJAX unit test and I get this error. Serialization of 'Closure' is not allowed Things I installed wp scaffold plugin testplugin (also can use wp scaffold plugin-tests ...
  • 181
0 votes
1 answer
23 views

How to call php file in theme directory from plugin

The goal is to reuse some part of code to login and logout user in ajax with or without reload page . I can't call the content of php file ajax_user.php inside wordpress template directory from my ...
  • 11
0 votes
0 answers
21 views

How to detect if the ajax_query_attachments_args was triggered to set the featured image?

I'm trying to filter the attachments when the user tries to set a featured image for the current post, but this affects all the ajax_query_attachments_args hook requests, like the one in the upload....
0 votes
0 answers
19 views

Wordpress ajax response save into database

I have this code which grab playlist from youtube and through foreach and ajax send data to wordpress function to save into database. IT is not working, i know somewhere i'm doing wrong but unable to ...
0 votes
0 answers
39 views

WordPress custom post type numeric pagination with ajax

I have a custom post type called "project". At the moment the pagination is with page refresh. What I want is to add a numeric pagination using AJAX with no page refresh. I was wonder what ...
0 votes
0 answers
30 views

Need help creating asynchronous data scraper in WordPress

I need some help on a data scraping script I've been working on. I want to create a script through which content can be extracted from a page. I fetched the page via wp_remote_get() and ...
0 votes
0 answers
29 views

How to split AJAX response into two divs

How I could get AJAX response splitted in two separate divs? Situation: I have custom post type (case-studies) filter by custom taxonomy(case study category). On page load I query by exact category. ...
0 votes
1 answer
95 views

How to set variables with AJAX request to use in another function in WordPress

$.ajax( { method : 'POST', dataType : 'json', url : my_var.ajaxurl, data : { foo : foobar, ...
0 votes
1 answer
33 views

Problems implementing Load More functionality

I’m trying to create my own Load More functionality (on click) in my child theme using the latest standards in Wordpress. I’m not comfortable working with the php parts of things and I’m getting very ...
  • 29
0 votes
0 answers
42 views

admin-ajax.php returns 0 even when the post status code is 200 OK

I've seen a lot of similar questions and I've incorporated the feedback from the answers but still, the issue is not resolved. Ajax request is sent on click of a button in js file. WyrRoute.js ...
0 votes
0 answers
58 views

admin-ajax.php error 500

I keep looking my error , but I can't find it. My php and js script works fine 5 month ago when I let them to dedicate myself to design Normally this ajax query must be launch from my plugin ( and ...
  • 11
0 votes
0 answers
48 views

admin-ajax.php 500 error when new users try to register

I have WordPress website and I get admin-ajax.php 500 error when new users try to register. jquery.min.js?ver=3.6.0:2 POST https://example.com/wp-admin/admin-ajax.php 500 send @ jquery.min.js?...
0 votes
1 answer
18 views

Why Wordpress AJAX returns undefined however it works fine when I add static url instead of dynamic function?

Code from functions.php function university_files() { wp_localize_script('main-university-js', 'universityData', array( 'root-url' => get_site_url() )); }; add_action('...
1 vote
1 answer
50 views

woocommerce search by sku and title ajax

This snippet works only in Title and i need to add also in Metakey SKU. <?php // Ajax Search. function thb_ajax_search() { check_ajax_referer( 'thb_autocomplete_ajax', 'security' ); $...
  • 149
0 votes
0 answers
24 views

Get URLs for AJAX Filter Checkboxes WordPress

I have a problem with showing and generating URLs for the pre-checked filter. So basically I need links for a specific filter, for example, I'm choosing the Location, the Salary, the Type of Work and ...
0 votes
0 answers
14 views

How to display contact form 7 form in vanilla js without jquery in frontend

Backend jquery Frontend Vanilla JS Contact form 7 Wordpress I have a task to display a cf7 form on the frontend using vanilla javascript . From what I've read, this can be done using admin_ajax.php. ...
0 votes
0 answers
24 views

WordPress Conditional / Multiple Taxonomy Query

I am trying to create a custom WordPress taxonomy query with multiple but conditional statements. However I am having issues when more than one taxonomy query is added to the statement. $tax_query = ...
  • 1
0 votes
0 answers
38 views

Validating an email input from form field before submit using JQuery, AJAX, and PHP

I have a form and one of the fields is an email with id email and after the user inputs their email and clicks outside the field, I wish to get the value of the email and then use ajax to pass that ...
  • 1
0 votes
0 answers
43 views

Why does PHP called with Jquery AJAX not allow additional php code to be added?

I wrote a plugin a few years ago that successfully uses AJAX and then recently I tried to add more of the same functionality but it fails. In the PHP files, I localized admin-ajax into the JQuery ...
0 votes
1 answer
36 views

Error sending array data from php to javascript

Sorry i see that here is heap of similar questions, but i will be dare to ask the same. I'm sending javascript two dimensional array to PHP script and then it saved to database. I'm using JSON....
0 votes
0 answers
30 views

Wordpress Ajax Not Firing

I've been out of the WordPress game for a while now and I'm just getting back into it. I'm trying to practice calling a PHP function via Ajax but I'm not able to get the Ajax call to even fire (when ...
  • 123
0 votes
0 answers
24 views

Pagination don't work with active filters

I'm make a custom theme para Wordpress and all works fine except the pagination when the filters are active. The console return 400 error and the navigation show /wp-admin/admin-ajax.php?paged=2 The ...
0 votes
1 answer
37 views

Message notification for user

I want to create alert system for users. If user get message I want to show info andout it near user image in header. So I create table for message id_message | id_user | sender_name | sender_email | ...
0 votes
1 answer
32 views

Upload data from weather station to Wordpress Website

I have built a weather station based on a Rasperry Pi. The weather data should be sent to a Wordpress website in regular intervals (about every 5 to 10 seconds). There the data should be displayed in ...
  • 3
0 votes
0 answers
126 views

Best practice: Custom Post Type / Filter / Load more

Good morning, I have a WordPress website which has a custom post type events. In the frontend, I simply retrieve my events and display them: $args = array( 'post_type' => 'events', '...
0 votes
1 answer
37 views

Can't get AJAX call working in custom plugin

I'm in the process of building a plugin using the Boilerplate linked in the official WordPress documentation. In my plugin I want to make an AJAX call (on button click) that runs a function and in ...
  • 829
1 vote
0 answers
34 views

Problems with wordpress nonces in Ajax call

i am having big troubles with Wordpress nonces in ajax call. Basically i am trying to trigger a custom standalone php script i made on my custom theme that send emails to admins people whenever ...
0 votes
2 answers
36 views

Custom AJAX Endpoint not returning any result

Hello I'm new to Wordpress and I'm trying to create an ajax endpoint that outputs JSON so I can access it through jQuery Datatables. I'm using Air Light theme for my current site and what happens when ...
0 votes
1 answer
52 views

Trigger a JavaScript function based on the data fetched from Woo commerce hook

I have read quite a lot of possible ways to do it but after going through each of them I'm still not able to understand what should be the correct way of doing it and how the correct way works. ...
1 vote
1 answer
62 views

WordPress notification if new post published

I use WordPress and I want to alert users if new post with post_type = job_post was published. Also I want to show amount of new post. So I add to function.php global $new_job_count = 0; function ...
0 votes
0 answers
19 views

Sharing variables in both actions wp_footer and wp_ajax

I have some code in my functions.php that, under a specific time condition, showes a popup that notices about some database update routine. What is happening here, is that when this condition happens, ...
0 votes
0 answers
20 views

Ajax Favorite from foreach (how to specify which result result is processed)

I created my first ajax script which is an add-to-favorites option on my real estate site. On the single property page the setup works great...I check if the property is already saved, display a ...
  • 3
0 votes
0 answers
31 views

Ajax call not working in wordpress through a plugin

I have 2 Ajax call the first is working but when it send the data to other the file send_data.php and when I try to run any wordpress function which is add_post_meta it doesn't work! This's the first ...
  • 5
0 votes
1 answer
28 views

Send Array from JS to php file then insert it in wp database through a plugin

This's my code it's success but when but I can't the return data from ajax in the same page. the mechanism is the user click the dropbox button and when he selects it returns dropbox_links and then ...
  • 5
0 votes
0 answers
30 views

custom add note meta box with add button in wordpress

I'm making a custom note meta box for plugin, and I have a note box input and one 'add' button in the box with. The button saves the text but does not move the text to the notepad but instead stays in ...
0 votes
0 answers
17 views

Get uploaded attachment width & height and attachment ID after upload them

I will explain my requirement here. Im trying to redirect window to wordpress image editor once image is uploaded via wordpress image upload window. also this redirection should only happen if image ...
1 vote
1 answer
34 views

Admin ajax error 400 when passing select value to populate another select

This is my first attempt to write a plugin and I get an error 400 when trying to use admin-ajax.php. I've looked through some topics both here and in the WordPress support forum, but cannot figure it ...
  • 113
0 votes
0 answers
111 views

Wordpress Custom Add To Cart Button with AJAX

i made a custom add to cart button but i cant load it with ajax here is the code. i added this code into my functions.php // Add "Add To Cart" button // add_action('...
  • 1
1 vote
1 answer
39 views

How do I get reusable blocks via frontend REST API?

I'm using /wp-json/wp/v2/blocks to request all blocks on the frontend, but I just get a response of [] even though I've made a reusable block in admin. I suspect that what I mean by block and what ...
0 votes
0 answers
31 views

can't unzip file

i'm created import and export function, The Export function download zip file to my computer The Import function when trys to extract zip file it's fails and can't open zip file. when i create the zip ...
0 votes
0 answers
18 views

How to change request URL?

My website has a plugin that makes requests to url mydomain.com/wp-json/... If url contains ?lang=en request goes to mydomain.com/wp-json/?lang=en/... and drops 404 error "No route was found ...
  • 1
0 votes
0 answers
64 views

change wordpress pagination url after doing the request

I'm working with Wordpress pagination, I want to modify the returned URL when I click on a pagination link (number 2 for example in the pagination), at the moment I get: https://magicpallet.com/blog-2/...
  • 3
0 votes
0 answers
37 views

Wordpress function not defined in AJAX call

I need to send some data to my user meta with ajax and when I click on my link where the function start, I got a fatal error caused by undefined function. But when i try my function with a form to ...
0 votes
0 answers
129 views

Why the wp_localize_script() does not work correct in my case? ( /wp-admin/admin-ajax.php 400 (Bad Request) )

Hi I use the next environment for adding the script and style to my WordPress theme: function theme_scripts() { // Load the html5 IE. wp_enqueue_script('iceers-html5', ' https://cdnjs.cloudflare.com/...

1
2 3 4 5
53