Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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-...

0
votes
2answers
26 views

How to use wp_mail in CPT page

I have a CPT and inside the CPT I have a contact form. The contact form directly sends to WordPress dashboard, Now I'm trying to implement when a user submits the contact form they will receive a "...
0
votes
0answers
13 views

ERR EMPTY RESPOSNE on ajax delete request in wordpress

I am trying to delete a post with REST api endpoint. evry thing is working fine on local. but on live(000webhost server) its giving error with no response text. http://mylivesite/wp-json/university/...
1
vote
0answers
14 views

Pass additional parameter with async upload

The following image: is showing what i want to archive. It shows the default admin upload widget in where i added a checkbox that once checked would pass an additional parameter with the async upload ...
0
votes
2answers
46 views

Unset session variable on page reload / setup but exclude AJAX

I'm currently trying to unset a session variable in WordPress if the page get's reloaded. I've tried a lot but it's not working like I want it. This is my function: /** * Unset filter session if ...
0
votes
0answers
17 views

Unexpected results when passing WP_Query from Search and Filter Pro to Geomashup, with the results updated via AJAX

I'm using two plugins in tandem, GeoMashup and Search and Filter Pro. Geomashup is generating a contextual map of posts from search results passed from Search and Filter Pro. I need the results ...
0
votes
0answers
20 views

WooCommerce filter shop page without any plugin via AJAX

I've build a fancy dropdown filter at the top of the WooCommerce shop products list: The list gets filled from a custom product meta called hardness. It can has 3 values: big, middle and small. The ...
-1
votes
1answer
96 views
+50

Theme making direct ajax calls to theme folder

So, I'm using a wordpress theme (unfortunately, I'm not able to get support for the theme any longer), and it has a contact form that makes a direct ajax call to a php file in the theme's "includes" ...
0
votes
0answers
27 views

admin-ajax.php 403 forbiden?

I am trying to auto populate fields of WP User Frontend WordPress plugin. I tried copying inspected code, and directly creating a template with this code, and it is doing good job, expect, it gives me ...
-1
votes
0answers
26 views

strange behavior with update_post_meta

I am updating custom post meta values through a frontend form with ajax, and i have two fields, one is a select form and the other is a Bootstrap Datetimepicker input, which i've localized to Arabic. ...
0
votes
1answer
34 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 ...
0
votes
0answers
17 views

How to do action after successful post save/update

On the frontend, users can submit a post, and when they click a submit button, javascript uses AJAX to publish the post to the live site. However, to automatically moderate the posts, I want to run ...
0
votes
0answers
25 views

Assign variable of Wordpress plugin to value of a javascript variable

I know there should be a way to achieve this but, unfortunately, I’m a newbie to PHP and I really need your kind assistance here. I spend hours to find a solution, have no hair left to pull out of my ...
-1
votes
0answers
16 views

wordpress admin-ajax.php 400

Playing since hours around. Getting every Time a 400 and a return of 0. $('.save-date').on("click", function () { var pickrDate = $(this).parent().parent().find('.date-pickr').val(); ...
1
vote
1answer
20 views

'is' functions and 'get_query_var' not working

Why does is functions not work inside an Ajax function? Except for is_user_logged_in? I also tried using get_query_var and it did not work. jQuery: jQuery('.post-modal').live('click', function(e) { ...
0
votes
2answers
31 views

admin-ajax GET response bad request

I don't like to use wordpress, but I'm working on a business client website that want to use it but without the default wp- prefix for files and folders.To find a solution and to try satisfate this ...
0
votes
1answer
14 views

wp_ajax function return the html page

I´m trying to do a plugin feature : download a file by a button click using wp_ajax feature. I already used wp_ajax but in this case I did not find my error. When I click on the button, it runs ...
1
vote
1answer
24 views

WP Admin AJAX Security - using POST to include a relative URL

I have set up several WordPress Admin AJAX scripts (that run only in the Admin panel) that currently all use separate actions, functions and nonce's. The only "real" difference between these scripts ...
0
votes
0answers
16 views

Offset with ajax load more posts duplicates

I have a shortcode that gets posts. I am using the shortcode three times on the page. The first time I grab the first 6 posts, the second time I offset by 6 and grab the next 4 posts, the third time I ...
1
vote
1answer
17 views

How to handle 400 status in Ajax [duplicate]

I have created a page in wordpress which is hosted in localhost. The page containing two drop down lists. one is for selecting category lists from a table called 'category' and the second drop down ...
0
votes
2answers
34 views

AJAX Implementation

Am try to implement data from database using AJAX based on a drop down list in WordPress. The codes returning 400 bad request in the console. I am hosted the page as localhost. Here is my theme's ...
0
votes
1answer
20 views

Removing Product from Woocommerce checkout page using Ajax

I have added remove button for products in the checkout page. The code - function add_delete( $product_title, $cart_item, $cart_item_key ) { if ( is_checkout() ) { /* Get Cart of the ...
0
votes
0answers
32 views

wordpress global variable $menu inside a ajax function not working

i am new wordpress , i am trying to display global variable menu using ajax call, but inside the ajax function the variable is not working. please help me how can i print the value of global $menu by ...
0
votes
1answer
11 views

Load oEmbed iframe within ajax call

I'm trying to load oembed shortcode loaded via ajax. The problem is that the oembed shortcode seems to work as I have a blockquote instead of the instagram link. However the blockquote is not ...
0
votes
0answers
11 views

AJAX and History API for the default wordpress pagination

What I want to achieve is AJAX-ified pagination for the WordPress archive/pages/posts etc meaning that I would like to keep the standard URL structure: example.com/page/2/ but using the combination ...
0
votes
1answer
18 views

Post data across Wordpress sites

I have two Wordpress sites. When I click on a link on Website A (the link is a country) I would like it to navigate to Website B. Website B would then display a list of results based on the link ...
-1
votes
0answers
14 views

add_to_cart_url shortcode adding another product on refresh

I am currently displaying an 'Add To Cart' button in WooCommerce for a variation using a shortcode like this... [add_to_cart_url id="746"] This is working correctly, but now if the customer clicks ...
0
votes
0answers
16 views

Sage 9 Sort Blog by Category using Ajax

I'm using the Roots starter theme Sage 9. On my blog page, I have created a dropdown of all the categories with their URL as the value. I’m still learning how to use ajax but I am trying to load posts ...
0
votes
1answer
83 views

In WooCommerce product archive, how can you also set the quantity to be added to cart by typing, instead of just by using +/-?

As it stands right now, in WooCommerce 3.5.1, at product archive (the /shop page), if you use the +/- buttons to set a quantity before clicking "Add to cart", all is fine. But if you try to actually ...
1
vote
2answers
83 views

How to Globally Use wp_localize_script() Ajax URL

I have added this to my functions.php and need to use ajaxURL in all of enqueued scripts in the template (instead of enqueuing only one script here add_action( 'wp_enqueue_scripts', '...
0
votes
0answers
16 views

Should I check for privileges before hooking into `wp_ajax_$handle` or after?

Should I heck for privileges before even hooking the wp_ajax_hook_name or in the function that I've hooked to it? The first way: if( current_user_can( 'manage_options' ) ) { add_action( '...
0
votes
1answer
15 views

Shortcode to pull posts

I need some help please. I have created a shortcode to pull in posts, then using ajax it loads more posts. I have everything working but it is duplicating the first group of posts. below is my code. ...
0
votes
0answers
21 views

AddToAny Share Buttons VS Ajax Load more

AddToAny Share Buttons are working for normal post. But when ajax load more button is clicked, the share button is generated with the new post but no share link is generated. The same is happening for ...
0
votes
0answers
26 views

My post loop needs to have 8 different post templates

Firstly let me just say I am a beginner with backend but have learned a lot the past few weeks working on this backend project my company has allowed me to work on. I've learned to use Ajax, create ...
0
votes
0answers
19 views

AJAX is not submitting data to database

I have a quiz application which stores user scores to a variable. There is a blueprint object for every user that looks like this: function User (theName, theEmail) { this.name = theName; this....
0
votes
1answer
31 views

Any possible way to make $wpdb->get_results() return anything else than array?

So I'm using $wpdb->get_results() to query my database and then make AJAX call from JS file. The problem is that I need to get the value itself, like a string, instead of array, but as much as I ...
0
votes
0answers
13 views

AJAX request returns back Array0 to console

I'm making an AJAX request in wordpress for the first time and I'm trying to access my custom made table to retrieve single name (string) or multiple names. It all works without the errors, except for ...
-1
votes
1answer
24 views

Can't access data from database using AJAX

I'm trying to make an AJAX call for the first time in wordpress. I followed some tutorial and have came to this point so far. But when I'm trying to console.log the data I get from database inside my ...
0
votes
1answer
29 views

Wordpress ajax error 400 bad request for sending data to remote site [duplicate]

I am using Sender.net for email subscription lists. This site give me some information to add user's emails to subscription list. I want to use WordPress ajax to for this. but it return error 400 bad ...
0
votes
1answer
22 views

Ajax call from Plugin using Class

I'm making a plugin with a class and methods. This class gets called through the theme ( hard coded ) to enqueue and localize my js. it also prepares it for ajax. However, i keep getting ERROR: 400 ...
3
votes
1answer
93 views

How would I get a taxonomy/category list inside a Gutenberg block?

I would like to display a dropdown list of categories (or other taxonomy) inside of a Gutenberg block. I can only think of two ways to do this: Create an array of the taxonomy in php and use ...
0
votes
0answers
16 views

Adding pagination to Ajax Query

I have a search page. It works like this. (1) User searches using form in the homepage (2) User is taken to search results page (3) If user modifies the search term( there is form with in the search ...
0
votes
1answer
17 views

$_SESSION inside php function executed by AJAX

I am defining $_SESSION['session_test'] from $_POST['reason'] I get from AJAX call. Inside of this function, $_SESSION['session_test'] does get defined, and I get desired echo result. add_action('...
0
votes
0answers
15 views

Show formatted custom post type with custom fields on page

I have created a custom post type called device using 'Custom Post Type UI' plugin. For this post type I've created some custom fields with 'Advanced Custom Fields' plugin. To show custom post type I'...
0
votes
0answers
24 views

Problem with google recapcha and wordpress ajax login

I'm using google recapcha for validate my ajax login form in wordpress, everything is ok and ajax form worked very well! but when i add recapcha and send it value to validate i give error 400 bad ...
0
votes
0answers
30 views

WooCommerce change order status using Ajax

How can I change the status of an order from Completed to Cancelled (or any other status for that matter) using Ajax?
0
votes
1answer
21 views

Two same AJAX calls - one is working, other doesn't

I am developing a WP plugin. I have two same AJAX calls, one is working, and second one is giving me 400 Bad Request error for admin-ajax.php. ReadyState is 4, responseText is: " ↵ ↵ ↵ ↵ ↵ ↵ ↵ ↵ ↵ ↵ ...
0
votes
0answers
12 views

Is it possible to remove a conditional value from WordPress custom metabox

Here I have attached the screenshot from MySQL for easy understanding. In this meta value a: denotes total no of users liked the post. User denotes user with id user-id My question : Is it possible ...
0
votes
0answers
17 views

Post Meta deletion ajax not working

I am trying to remove function in the backend of post like plugin. In the post like plugin they are storing values in the following manner that is User Id , Post id and comment (or) Post . ...
0
votes
0answers
20 views

Populating a Select Box from another select box

I have a select box on a form that gets board types from the ConnectWise api and is populated as such: <div class="form-group"> <label for="support_type">Support Type</label> ...
0
votes
1answer
68 views

ajax multiple Values

i tryed to return multiple Values from an Ajax Call, I would Like to retun Value a and value b in two separat Variables in my Ajax function. Is it posible to do that? or could I use an Array? Or ...