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
1
vote
1answer
3k views

how to make custom ajax handler?

i'm trying to make custom ajax handler because the admin-ajax.php is taking to long to handle ajax requests from 7s to 10s so i google it and mange to do some custom ajax-handler.php like this <?...
0
votes
0answers
17 views

Sanitize $_POST and $_GET with array_walk

Today I was working with lots of form input which i had to transport through ajax calls. So I wondered if there was a smarter way to handle $_POST (or $_GET) arrays in one go. I came up with this: $...
0
votes
2answers
7k views

What is the best way to implement ajax based pagination on custom query based templates?

We can use multiple plugins like wp-pagenavi or wp-paginate for implementing pagination for wordpress sites and making it ajax based using the following code: jQuery(document).ready(function(){ /...
0
votes
0answers
7 views

How to filter my post Using ajax based on category on woocommerce products?

I have created a custom template for the shop page and displayed the woocommerce products. I want to sort the products based on category without loading the page preferably using ajax This code use to ...
0
votes
1answer
940 views

Apply filters when loading post via ajax

Have been trying to solve this for couple of hours already. Here's the case: I'm making a plugin that separates the posts into pages using the <!--nextpage--> tag. It works fine but I want to ...
0
votes
1answer
673 views

403 (Forbidden) delete file image in themer folder

I'm having trouble with permission to delete files that are within the theme folder. All folders and files are with permission 775 and there is no error in the code , because when I use the code in a ...
0
votes
1answer
840 views

How to use `foreach()` in ajax call

I have written a code for retrieving data from the database using the ajax for WordPress. The following code is the one written in the functions.php. The code is for getting the id and names of ...
1
vote
1answer
588 views

Return an array from get_terms and store as JavaScript array for search autocomplete

I am trying to use wp_list_pluck to return an array of taxonomy names from get_terms. I'm not sure what I'm doing wrong, but this only echo's out "Array": $terms = get_terms(array( 'taxonomy' ...
0
votes
1answer
706 views

Pass the updated value of aid from form using ajax

I am working in wordpress and I want to fetch the updated value of aid field from form each time a submit button is pressed. There are two submit buttons and I want the id as per the clicked row HTML ...
0
votes
1answer
62 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 ...
32
votes
14answers
81k views

Admin Ajax is returning 0

I am relatively new to jQuery and AJAX in particular. I have a small issue with the return value always being 0, though I think this is actually the success message and it's not returning anything. I ...
0
votes
2answers
1k views

Registration form not registering First and Last name

I'm creating a custom registration form which works using username and email inputs, but when I include First and Last name fields it won't let me register. Here is the form: <form id="...
1
vote
1answer
1k views

How to export custom database data to excel file

Hi everyone I have the code below, but when I click on the link generated a new page is open with 0 display on it. What I'm doing wrong? function list_reservation_to_csv() { global $wpdb; $...
0
votes
1answer
947 views

Dynamically load posts based on category

I would like to load posts based on which categories are selected. The load should be done without refreshing the page. My first thought was to include AJAX in a wordpress function, but I want to know ...
0
votes
0answers
13 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
1answer
866 views

Quick Edit: Selected Custom Taxonomy Not Refreshing After Save

This seems to be a common problem as it was asked here but I can't seem to fix it on my own installation. I've setup a filter to modify the quick edit button to identify the correct selected value for ...
0
votes
1answer
1k views

Change button text after ajax db update

I'm trying to learn serious php WP developing. My goal is to mark posts done/read on button click. I found this great ajax tutorial plugin. Here is the link of the tutorial, and for the plugin. I ...
0
votes
0answers
38 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() { ...
1
vote
1answer
3k views

Setting value of session with Ajax not working

I´m kind of new to using Ajax but I am trying to update the value of a session using Ajax. The Ajax call shoud fires when clicked on a button. When I click on this button it also returns the succes ...
0
votes
1answer
637 views

processing form data with ajax

I have a form coded below <form id="language-registration"> <?php global $wpdb; $results=$wpdb->get_results('SELECT * FROM keeled;', ARRAY_A); $keeled=$wpdb->get_results('...
0
votes
0answers
20 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
417 views

WooCommerce | AJAX | Product Pagination | Help me implement Ajax Pagination

Im struggling to find a good resource on implementing my own AJAX product pagination onto products within the WooCommerce shop loop. Please can someone guide me on how is best to load more products ...
0
votes
0answers
17 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
1answer
68 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
21 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
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
23 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
832 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
1k 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
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 ...
2
votes
1answer
828 views

Why does Wordpress Heartbeat login not refresh the nonces?

Here's an interesting experiment: Go to wordpress plugins listing page, notice the activate, deactivate links all have a nonce part in the request. In a second tab, log out of the site, and go back ...
0
votes
1answer
24 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 = ...
0
votes
1answer
1k views

AJAX login without a plugin does not work. when add a action to function.php

I am using wordpress ajax login without a plugin. I want to not be allowed users access to the WordPress profile after login, Because i have designed a specific profile in the link: http://www....
0
votes
1answer
583 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: ...
1
vote
1answer
1k views

Making an ajax request from a different domain

I'm making an ajax request from my primary domain to a subdomain. I've solved my cross origin issues so I'm not getting an error. The call is returning data:0. I've checked my response config and the ...
1
vote
1answer
64 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

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
0answers
27 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 ...
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
36 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 ...
2
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(...
1
vote
2answers
43 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" ]; $...
1
vote
2answers
1k views

AJAX not Working with php as supposed

I am creating a like system in PHP . My code looks like this . <?php class Like_System { private $userid; private $postid; private $user_ko_like_count; private $post_ko_like_count;...
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
2answers
120 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
23 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
vote
1answer
219 views

How to add WP API and JS featured image attachment

I would like to fetch the image from the wordpress rest api - I have the following code: HTML: <div class="post-item"> <div id="posts">Loading posts... </div> Ajax script: <...
0
votes
0answers
37 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
14 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 ...

1 2
3
4 5
48