Can’t access data from database using AJAX

Pass data as an argument in done(function(data) funtion. <script> jQuery.ajax({ type:”POST”, url: my_ajax_object.ajax_url, data: { ‘action’: ‘call_my_ajax_handler’ } }).done(function(data) { console.log(data); });

Load css classes after using ajax calls

Styles won’t be affected if you use different selectors. Create a custom stylesheet, and enqueue it immediatelly. When the page is ready just apply the styles to the mentioned responsive div, or create some logic behind it. So for example if you have <div class=”custom-sidebar”>Some content</div> Enqueue custom style within functions.php wp_enqueue_style( ‘some-custom-styles’, get_stylesheet_uri() . … Read more

List of pages – AJAX load more

Previous Question That answer I’ve linked to shows the steps you’ll need to take. It probably didn’t come up in your searches as you weren’t using the right terms. As you’re a front-end dev, this is how I’d do it based on that persons advice. Don’t load anything in the template. Just have an empty … Read more

Ajax Load More or View More functionality for woocommerce category layout by template overriding

You can achieve this by create a template override for woocommerce category layout. How to Create Template override Go to wp-content/theme/{your_theme} Create a folder named woocommerce if already not exist Then create a file titled archive-product.php Now, paste the below code as instructed and modify any parameters per your need Add this code right after … Read more

Ajax not working for logged in users

Probably it’s because of this: add_action( ‘wp_ajax_my_action’, ‘my_action_callback’ ); add_action( ‘wp_ajax_nopriv_my_action’, ‘my_action_callback’ ); You have to add the action for both hooks. Probably the plugin is hooked to the second hook right now. You can read more in the docs.

Display post content from category name using ajax

add_action( ‘wp_ajax_nopriv_load-filter’, ‘prefix_load_cat_posts’ ); add_action( ‘wp_ajax_load-filter’, ‘prefix_load_cat_posts’ ); function prefix_load_cat_posts () { global $post; $cat_id = $_POST[ ‘cat’ ]; $args = array ( ‘cat’ => $cat_id, ‘posts_per_page’ => 3, ‘order’ => ‘ASC’ ); $cat_query = new WP_Query($args); if($cat_query->have_posts()) : while($cat_query->have_posts()) : $cat_query->the_post(); $response=”<div class=”the-post”>”; $response .= ‘<h1 class=”the-title”>’; $response .= ‘<a href=”#”>’. get_the_title() .'</a>’; $response … Read more

ajax form function error

This error is telling you that there was a 500 error in the PHP of your AJAX callback: jquery.js:8625 POST /admin-ajax.php 500 () This would be caused by a syntax error or other coding mistake. In looking at your code one obvious major problem is here: // use \Aws\Polly\PollyClient; // this was moved to before … Read more