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

15 30 50 per page
1
2 3 4 5
90