Why does my Ajax Get request give a 400 bad request?
Your nopriv action has wrong syntax. add_action(‘wp_ajax_nopriv_test’, ‘do_ajax_get’);
Your nopriv action has wrong syntax. add_action(‘wp_ajax_nopriv_test’, ‘do_ajax_get’);
Figured this out now. Instead of using $wp_query->set(), I instead set arguments, and then ran the woocommerce loop. This is the final code I used. add_action(‘wp_ajax_listFilteredProducts’, ‘listFilteredProducts’); add_action(‘wp_ajax_nopriv_listFilteredProducts’, ‘listFilteredProducts’); function listFilteredProducts($wp_query) { if(isset($_GET[‘formData’])) { $value = $_GET[‘formData’]; } // If no price input, but tags have been input if ($value[‘priceRange’] == 0 && $value[‘tags’] != … Read more
@HappyArif You just kept a line in your code that needs to be changed if there is a Category selected. $args = array( ‘orderby’ => ‘date’, ‘post_type’ => ‘course’, ‘posts_per_page’ => -1, ‘tax_query’ => $tax_query, ); This have ‘posts_per_page’ => -1 which needs to be changed to ‘posts_per_page’ => 9, ‘paged’ => $paged to make … Read more
Hence, ajax calls that must be triggered from within the wp admin panel should be registered via the wp_ajax_{$action} hook, and ajax calls that are triggered from the frontend and have totally nothing to do with wp-admin, but are like simple REST interactions of your platform users with your platform server, should be registered via … Read more
This isn’t specific to WordPress, but I’ll answer it anyway 🙂 Don’t target the form by id, instead target it by its relationship to the button that was clicked. change: var str = $(“#ajaxForms”).serialize(); to: var str = $(this).parent().serialize();
your ajax url is wrong i think. ajax link should be admin_url( ‘admin-ajax.php’ ). That means wp_localize_script(‘history_script’, ‘myAjax’, array(‘ajaxurl’ => get_template_directory_uri().’/functions.php’)); will be this wp_localize_script(‘history_script’, ‘myAjax’, array(‘ajaxurl’ => admin_url( ‘admin-ajax.php’ ));
the_permalink and the_title (by default) echo their value, and therefore can’t be used in assignment. Use get_permalink, and the_title( ”, ”, false ).
This link to the WordPress Codex should help. It demonstrates a few different ways to POST using AJAX in a plugin. As for re-arranging your listed elements, this can be done a number of ways. I would recommend running a search for rearranging elements using javascript. The jQuery function .insertBefore() and .insertAfter() can be used … Read more
There is a fatal error in the theme you are using. When I checked the response in firebug console, I got the following error Fatal error: Cannot use object of type WP_Error as array in /home/content/s/b/r/sbrenan/html/peteshighway.com/wp-content/themes/peteshwy/functions.php on line 96 Either you fix this or contact with the theme support team.
Use COOKIEPATH and COOKIE_DOMAIN constants. setcookie( ‘welcomeback’, ucfirst( $_POST[‘firstname’] ), strtotime( ’27 Feb 2017′ ), COOKIEPATH, COOKIE_DOMAIN );