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

Any ideas why I am getting “I'm getting ”wp-admin/admin-ajax.php 401 (Unauthorized)"

I'm running locally on Windows 10 and I'm a full admin on my computer. Any ideas? Basically I'm trying to send an email from the form. I just started the code and wanted to test that the ajax was ...
0
votes
0answers
9 views

How to load WP-Postratings via AJAX?

WP-postratings Adds ratings to WP. It's the most downloaded ratings plugin on the repository. Votes are sent via AJAX but the rendering of the plugin is not. As a result when using a caching plugin ...
0
votes
0answers
29 views

I am getting Admin-ajax.php 400 Error

I am implementing some changes to my website's page with AJAX. I have enqueued my js file in functions.php add_action( 'wp_enqueue_scripts', 'add_my_script' ); function add_my_script() { ...
0
votes
0answers
15 views

How do I mitigate replay attacks when talking about actions that shouldn't happen twice?

A nonce is supposed to first help me against CSRF and help against replay attacks is just a bonus if I "personalize" the nonce to something like pay-user-{id}, but here's the problem - if my link ...
0
votes
0answers
16 views

WordPress admin-ajax.php not available for subscribers/contributors

I've implemented a simple category ajax filter using admin-ajax.php that works perfectly if the user is not logged in or if the user is logged in as an administrator. For everyone else, it calls the ...
0
votes
0answers
12 views

The woocommerce attribute filter loads very slowly, how to solve [closed]

I use wordpress to set up The attribute filter of woocommerce, when used, is loaded for at least 2 seconds, which is very slow. https://www.sasaspa.com/collectiontmr His website does not need to ...
0
votes
1answer
20 views

ajax response not recieving

Will anyone help me in this regard. My problem is that when I ajax request WordPress, when I log that response in console it shows error/complete not response. jQuery(document).ready(function($) { $("...
0
votes
0answers
9 views

Hide Load More Button When Finished [duplicate]

I've tried just about every code on here under the sun and for some reason my load more button is not hiding when there are no more posts to show. I'm using a custom post type and a custom loop to ...
0
votes
0answers
9 views

Problem with phpmailer WordPress [closed]

when I buy with Woocommerce I see the error "Internal Server Error" and into debug I see this problem: 2020-05-26T15:57:51+00:00 CRITICAL Cannot declare class phpmailerException, because the name is ...
0
votes
0answers
13 views

Alphabet filter for last name

I'm trying to filter my professionals directory by last name using ajax. Right now I have other filters working using custom taxonomies and a drop down menu, but am having a hard time finding ...
1
vote
0answers
17 views

Why Wordpress plugin url ajax doesn't work?

I need to send information to the plugin folder via ajax. Wordpress has a function for the link "plugin_dir_url (__ FILE__)" which works properly but if I put it in ajax it doesn't work. Function: ...
0
votes
1answer
56 views

Call a PHP Function with Multiple Parameters that is outside the AJAX Handler

Q: What is the correct way to call a PHP Function with multiple parameters from the AJAX Handler? Q: Am I calling the php function correctly? Q: Is there an easier way to do this? Page Element The ...
0
votes
1answer
18 views

post value to function with Ajax and jQuery

This is how you would create a custom smart tag in wp forms: function ea_custom_smart_tags( $content, $tag ) { if( 'my_smart_tag' == $tag ) { $value = 'Testing 1 2 3'; $content = ...
1
vote
1answer
12 views

Image upload via FormData API and AJAX is not working ($_FILES always empty)

When I try to do what's mentioned in the title, my requests all work (nonce check passes, and server response 200 receveived, and server - script also working properly). My problem is that I cannot ...
0
votes
0answers
23 views

Ajax and get_template_part

I found this https://stackoverflow.com/questions/33999193/wordpress-load-more-posts-onclick-with-ajax-request-jquery to load posts via Ajax. It works great except that I would like to use a template ...
0
votes
0answers
10 views

Filtering an autocomplete by a custom post type in Wordpress using Ajax

I've been following the below post in order to set up an ajax autofill input on my search. Populating autocomplete field with custom post type Unfortunately, I keep getting the following error: ...
0
votes
1answer
25 views

post values to custom post type which has advanced custom fields

I am trying to use Ajax and jQuery to post data to a custom post type. The title field works as is standard wordpress field but the color field does not. I also tried replacing 'color' with the name ...
1
vote
2answers
30 views

Wordpress api call using wp-ajax returns error 400

I'm quite new to doing api calls using Wordpress so bear with me. I have this function: function foo() { $userinfo = [ "number" => "26246426", "secondnumber" => "43634643" ]; $...
0
votes
0answers
10 views

Woocommerce Cart Category limit

I'm using the following code to limit products from one category in the cart. add_filter( 'woocommerce_add_to_cart_validation', 'only_one_product_category_allowed', 20, 3 ); function ...
-1
votes
0answers
12 views

access the data from ajax response.!

Is there any body i need little help plz. I’m trying to access 'id' from ajax response that is coming from database (in row_array()) but when when i alert it or console it i only get single bracket ( {...
0
votes
0answers
31 views

WordPress Ajax - Filter Posts by Category

I'm having trouble getting this Ajax tutorial to work - if anyone is able to help me figure this out it would be much appreciated. I followed the instructions step by step and have gone over the code ...
0
votes
0answers
13 views

Issue with WordPress AJAX Filtering breaking links on frontend

I've been using AJAX taxonomy/post filtering for the past week and just noticed something really strange upon further testing. When you select the filter criteria and click FILTER, it populates the ...
0
votes
0answers
9 views

Wordpress custom posts get subcategory

i have added custom post type in Wordpress that works like slideshow, all slides are clickable and open in products slug. how can i query posts subcategories that match with the slide clicked? code ...
0
votes
0answers
14 views

Wordpress New Post via ajax call

I have added this field to the Add New Post page And i get data via ajax into console, I want to update post title and content when i click button "Import Data". jQuery(document).ready(...
0
votes
0answers
10 views

Persist nonce across user sessions?

As per the WordPress Codex nonces are unique to the current user's session, so if a user logs in or out asynchronously any nonces on the page will no longer be valid. I am using a nonce to secure ...
0
votes
0answers
14 views

Update Woocommerce shipping cost when ajax request is made

I have google autocomplete api on my address field in checkout page and embeded map with polygons as delivery zones. Each zone has it's own delivery cost which also depends on order's total cost. When ...
0
votes
0answers
10 views

How to submit multiple nonces at once?

I have a form that incorporates three different forms from a plugin. Usually, each form would have it's own submit + nonce (which already exist and work), but I need to have just a single submit ...
0
votes
0answers
14 views

Ajax call of Wordpress function

Can someone show me a good example of how to call a PHP function with Ajax? I'm trying to save an image gallery (with dynamic number of images) to database in the admin settings section. The below ...
1
vote
1answer
26 views

Load More Posts Button - AJAX

I'm trying to add Ajax to my theme so I can load my posts dynamically. The following code works but for some reason when I wrap the button that fires the loading with another div it doesn't do ...
0
votes
0answers
12 views

WebSockets, Long Polling or Several Ajax Calls?

I'm setting up an Ajax Call which, when fired, is calling a php - script which carries out the following tasks, among others, in this sequence: upload an image to the server create a post associate ...
1
vote
0answers
13 views

Viewing checkout page removes fees from mini cart

I customized the mini cart to show a breakdown of fees (discounts) to the customer. This works however if you visit the checkout page, which also uses ajax to load cart totals, when its done loading, ...
0
votes
0answers
6 views

Store visitor preference until browser is closed (No Login)

I have a WordPress website that does not need a login. However, there is a feature in which the user can set what cloth size chart (e.g US or UK) the user will use. What should I use to store this ...
0
votes
0answers
16 views

Safari giving Undefined index error on AJAX POST submit in WordPress

I am developing a unique cart plugin on WordPress. I am having weird Undefined index error only on Safari. I don't understand why it is only on safari while working fine on other browsers. Please ...
0
votes
2answers
108 views

Woocommerce Multisite global search how to mod ajax function?

I created an installation of my multisite ecommerce to differentiate the men's and women's departments. Often, however, it happens that in the men's department they do research related to women's ...
0
votes
0answers
7 views

Theme functions don't work as expected in partial included via get_template_part() after custom query using Ajax [duplicate]

I am developing an custom theme which could be a child theme of any arbitrary theme out there that has custom theme functions defined. The home page is simply configured as list of latest posts. I ...
1
vote
0answers
7 views

Use AJAX to fetch Current Post Thumbnail for Wordpress when Uploaded throughMedia Uploader Frontend

i Use WordPress Media Uploader on Frontend to allow users to upload Thumbnail for there UGC site. I also show a Preview of the Image on Frontend. When a user clicks the button the Media Uploader opens ...
0
votes
0answers
26 views

Multisite Posts Ajax Pagination?

I am using Multisite and have the below code which pulls in posts from 2 sites. How can I add Ajax "Load More" pagination to the below code? Ideally when a "Load more" button is clicked it displays ...
0
votes
0answers
14 views

Front-end post trough ajax results in infinity loop

This code creates a post successfully but then it repeat is self over and over. var visitorData = { "title": 'TEST', "status": "publish" } var createPost = new XMLHttpRequest(); createPost....
0
votes
1answer
18 views

WordPress live search and filter custom fields

I have the following code intended to fetch, filter and display custom post on input(onkeyup). However, it sin't working at the moment; I also get a 500 (Internal Server Error) when I open the console....
0
votes
0answers
18 views

WordPress live search and filter

I have a grid of posts on my archive page. How can I filter through them once I start typing on the search bar, or filter by category on click, please?
0
votes
0answers
28 views

get_the_author_meta( 'ID' ) just return 1

I've a custom post type, and I want to get the author ID inside a condition in my function.php, and it just return 1 - as I can see with var_dump and print_r. If I use the same function directly ...
0
votes
0answers
13 views

price of product can't return when get data of product in functions.php

i create custom function to get all data of product to one category in functions.php function get_products() { $cat_id = $_POST['category']; $args = array( 'post_type' => '...
0
votes
0answers
10 views

Adding a second product at checkout via AJAX - Can I just manipulate the code, or do I have to copy it?

I have a checkbox that once checked, is checked by AJAX and a product is added to the cart. Do I need to duplicate the entire code or is there a cleaner way of adding a secondary product that does ...
0
votes
0answers
14 views

PHP - AJAX - field group array POST value always says undefined index

I have a group of two clonable fields name and email. So when user clones, they will have a set of name and email fields. Note: These fields are newly added to my code and AJAX was working fine with ...
0
votes
1answer
47 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
2answers
34 views

ajax request in wordpress

i create ajax request in functions.php function my_enqueue() { wp_enqueue_script( 'ajax-script', get_template_directory_uri() . '/js/script.js', array('jquery') ); wp_localize_script( 'ajax-...
0
votes
0answers
10 views

contact form ajax error response

I have this code that is supposed to stop the form if the nonce isn't correct. I'm not able to test my contact form, I will get the 'Errore' response and the emails are not sended. Is there a fix to ...
1
vote
1answer
23 views

wordpress and add actions to button by coding

I create my action in functions.php add_action('wp_ajax_myfilter', 'misha_filter_function'); // wp_ajax_{ACTION HERE} function misha_filter_function() { echo "my button action"; } How can i ...
0
votes
0answers
19 views

Can't GET Variable from AJAX URL

Trying to $_GET two variable from a URL generated by a HTML5 Construct 2 embedded game. http://wordpressexample.com/savescores.php?name=NAME_HERE&score=1337 Using <?php /** Sets up the ...
0
votes
0answers
27 views

WP AJAX Request Not Working

I'm trying to run wp_insert_attachment and update_user_meta using AJAX request but it doesn't work. js file import $ from "jquery"; class PersonalInfoUpdate { constructor() { this.events(); ...

1
2 3 4 5
47