Skip to main content

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.

0 votes
1 answer
1k views

How to get current_user_id from wordpress in node js?

There is a website on wordpress, in the plugins folder I have a project on Node js. In index.html (the client part, mostly js there), there is content that I have to show only to registered users. I ...
1 vote
1 answer
758 views

How to search using ajax for exact phrase or words in an input field?

I have been following this and it works almost perfectly but it is not only finding the title posts with the same words as per what we write in the input field but it finding ALL posts regardless. ...
0 votes
2 answers
1k views

WordPress + JavaScipt + AJAX + MySQL: insert query for form

I'm trying to make booking - plugin with form on WordPress-admin site, where I can add new event in calendar (made with JavaScript). I have to submit form with all data and insert data to MySQL ...
1 vote
1 answer
30 views

Load More : Admin Ajax 400 Bad request, returning 0

I've been struggling to create a Load More button on a WP project. Basically, I use the Admin Ajax at our disposal when using WordPress. I also use the fetch API to communicate with it, via my load-...
1 vote
1 answer
689 views

Scripts not appending to <head> element in AJAX call - why?

I'm trying (and failing), to get scripts to load in the header of certain posts before the rest of the page loads. Some of my posts have embeds that require scripts to work, but my makeshift code ...
1 vote
1 answer
916 views

Best place to load wp_ajax_the_ajax_hook action in plugin

I am building a shortcode plugin and I want to avoid loading unecessary code unless the shorcode is called in a page. I am having trouble with the ajax functions. It seems I need to load everything ...
1 vote
2 answers
2k 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
1 answer
1k views

admin ajax is not working for non logged in users

I know that this issue has been discussed many times, but I think I tried most of the advises. This is my code: $.post('<?php echo admin_url( 'admin-ajax.php' ) ?>', {'action': '...
0 votes
1 answer
2k views

Ajax the create and edit post form into lightbox and get results

So I have a Wordpress site I built that has custom post types and references to those post types inside others. Example: Custom Post Type 1 Custom Post Type 2 - References Type 1 on two fields Custom ...
0 votes
1 answer
2k views

wordpress ajax search posts

I tried to configure search area in wordpress using ajax, so i add this code into functions.php <?php // the ajax function add_action('wp_ajax_data_fetch' , 'data_fetch'); add_action('...
1 vote
5 answers
13k views

Ajax post returning full html page as response

I know that this has been frequently asked here, but none of the solutions I find seem to work for me. The issue is as follows: whenever I post the form, I have a console log with the response which ...
0 votes
1 answer
2k 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 ...
3 votes
1 answer
1k 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
1 answer
1k 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 ...
4 votes
1 answer
5k views

AJAX handler throws 400 (Bad request) - why?

I am trying to apply a "Load more posts" function to a post loop, but I am dealing with a 400 Bad request, when admin-ajax.php is referred to. The reference I used is this - https://rudrastyh.com/...
1 vote
1 answer
890 views

Help to upload post attachments from Ajax

My problem is that I cannot upload post attachments from a frontend form. I send data through AJAX to my php files containing functions. Let me be clear: everything is working great, the post is ...
0 votes
1 answer
1k views

ajax load more instead of pagination

<?php if ( ! defined( 'ABSPATH' ) ) { exit; } global $wp_rewrite; $wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1; $pagination = array( ...
0 votes
1 answer
2k views

Get ajaxForm response value

I have this ajaxForm: $('.simple-checkout').ajaxForm({ success: function (response) { console.log(response); alert("Success"); $('.cart-value').load(location.href); }, error: function (...
1 vote
2 answers
10k views

Dynamic dependent Dropdown lists for categories, sub-categories and posts

I'm using WordPress 3.5. I need a way to implement a code or plugin to allow users to navigate through posts using dependent(chained) dropdown lists. In other words I would like 3 dropdown menus to ...
0 votes
2 answers
2k 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="...
0 votes
1 answer
687 views

Ajax a php file that has Advanced Custom Fields in it

I am trying to AJAX in a php file that uses Advanced Custom Fields fields, and get a 500 internal error when making the request. The php file works fine if I just use ‘include’, but I need to have it ...
2 votes
1 answer
3k views

how load content as pop-up using ajax

There's a way to use ajax to load the content from single.php or a custom .php like ajax-single.php like this page does it: https://yellowimages.com/all/objects/apparel-mockups/ also like them show ...
0 votes
2 answers
5k views

Filter posts by categories ajax is showing all the posts

i'm try to filter posts by an cascade dropdown categories. But when i select an option of the cascade, he showing all the posts. How can i filter ONLY posts through the selected option? This is my ...
8 votes
5 answers
6k views

is_admin() returns true when using admin-ajax.php from front end script

Had a situation today where I was using admin-ajax.php from a front end script. As I understand it this the wp way to make ajax calls (registering my function with the wp_ajax_nopriv_myfunction hook) ...
0 votes
1 answer
2k views

Trying to run a Ajax request from a checkout form in woocommerce via a custom plugin

I have a custom plugin with the following code add_action( 'init', 'my_script_enqueuer' ); function my_script_enqueuer() { wp_register_script( "gift_card_redeem", WP_PLUGIN_URL.'/plugin-...
1 vote
1 answer
1k views

Ajax category filtering products default show all

I have code that list categories and products by category. When I click "All" it list all products, but when I go /products page it's not list all products by default and I need to click &...
0 votes
1 answer
1k views

How can I create a button that when clicked populates a div with a list of foods that are checked as a certain type of ACF?

I have not asked any questions here before so I'm sorry if I do it wrong. I am new to custom theme template files. I am new to wordpress and php also. This is a learning exercise for me. I am making a ...
3 votes
1 answer
2k views

Shortcodes not working in an AJAX call

I am using AJAX to load next set of posts on homepage. The posts load fine but the shortcodes are not rendered. I am trying to use the do_shortcode function on the content the ajax call fetches (...
0 votes
1 answer
2k 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
1 answer
721 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
1 answer
2k views

jQuery ajax method does not return data

I am sending email with phpmailer, I receive the emails when I press the "send" button, but I wanted to stay on the same HTML page, so I used AJAX script with HTML and PHP. The problem is ...
0 votes
1 answer
778 views

WP Cron as Fast as WordPress AJAX?

I have a question about performing a very long and resource intensive task within WordPress. Here is the scenario. I have a plugin that allows users to run a task that takes a very long time and ...
0 votes
1 answer
3k views

Get posts by category via ajax

In my page-members.php I output my list of categories <?php $args = array( 'orderby' => 'slug' ); $categories = get_categories($args); foreach ($categories as $category) ...
0 votes
1 answer
2k views

WordPress AJAX load post metadata in modal

I have a custom page template (front-page.php) and I have a custom metabox which is assigned to this page template. Metabox have 7 sections, and each section have 2 inputs. It looks like: 1. Client ...
0 votes
2 answers
866 views

Why Ajax Doesn't Work?

I have a separate page at the root of WordPress, for processing certain data, with the "wp-load.php" file connected to it. <?php require_once( dirname(__FILE__) . '/wp-load.php' ); ...
0 votes
1 answer
2k views

Failed to load resource: the server responded with a status of 404 (Not Found) admin-ajax.php

Failed to load resource: the server responded with a status of 404 (Not Found) admin-ajax.php while insert image in to post, and when I add custom html widget in to side bar this error will appear....
5 votes
1 answer
12k views

wp_query->max_num_pages always returns 0 on custom post type

Hi there I am developing a theme where I have to load some posts with ajax, in my index page everything works properly, the problem is when I need to use it on custom post type, I pass the values for ...
0 votes
1 answer
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
2 answers
975 views

Admin-ajax.php 404 error

im trying to submit the following form but it just wont work: HTML: <div class= "container"> <div class="row"> <div class= "col-md-10 mx-auto text-center&...
0 votes
1 answer
700 views

Admin Ajax returns "0 200 OK server error.." in Multi-site sub-site

I'm aware admin-ajax.php is intended to return '0' if there's no action set. My issue seems to be that it's returning an error after the '0'. Accessing the file mu.site.com/wp-admin/admn-ajax.php ...
0 votes
0 answers
25 views

I got this error POST https://localhost/meraboilerwp/[object%20Object] 404 (Not Found)

//this is my functions.php // Enqueue Styles function meraboiler_enqueue_styles() { wp_enqueue_style('google-fonts', 'https://fonts.googleapis.com/css2?family=Patua+One&family=Open+Sans:wght@...
1 vote
1 answer
3k 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 ...
3 votes
1 answer
2k views

How to Use JSON With AJAX?

I've defined a PHP callback function to handle the communication between server-side and client-side: function json_render_modal_body() { check_ajax_referer( THEME_PREFIX . '-modals', 'nonce' ); ...
0 votes
1 answer
1k views

How can I run two AJAX requests simultaneously in WordPress?

Kinda stuck here working with AJAX and trying to show posts based on user interaction. Right now I have it working where user makes a category dropdown selection and the posts load accordingly. What ...
0 votes
1 answer
2k views

change attachment custom field onChange event

The form is in post creating window. Ajax is posting values, but the values doenst renews. Where can be problem ? Ajax <script> function dynamic_Select(field, aid, value) { console.log(...
0 votes
0 answers
34 views

How can I display a Divi content inside a modal based on an AJAX request

This is my first question, please bear with me if I have forgotten any information. I want to show Divi content (saved as a WordPress project if it's important) inside an overlayed modal. For this I ...
0 votes
0 answers
23 views

Start a long running PHP process via JS/Ajax and monitor progress on admin page

I am developing a plugin, which can import layouts for a certain theme from a remote URL. Those layouts often contain a good amount of images and sometimes even videos. I have a admin page where the ...
0 votes
1 answer
777 views

duplicate posts with ajax load more wordpress

I have ajax loading posts on my site when scrolling. The problem lies in the appearance of duplicate posts. I cannot understand why this is happening. Only some posts have duplicates. Here is my code ...
0 votes
1 answer
132 views

AJAX request blocked by CORS policy

I have an issue with CORS policy. The request to retrieve URL is being blocked. I tried everything (Access-Control-Allow-Origin: * in .htaccess, theme's function.php, theme's header and wp-config.php ...
2 votes
1 answer
2k views

AJAX in plugin wp_send_json() sending html

I wrote a plugin that calls a PHP function from JQuery and the php sends a json response back to the Jquery using wp_send_json(). The functions are all called successfully, but the json request sends ...

15 30 50 per page
1
2 3 4 5
54