I’m beginner in jQuery AJAX too, and I always tried with $.ajax, but I’m using just $.post to my requisitions now and they work well. The syntax is more simple and less risk to make a mistake.
Obviously, if I’m wrong in this way, please someone alert me about it.
In $.post() you need to put the url, the variable would get by POST as object and a handler function(data,status). Just it.
In PHP code I just echo what I want to return to my page, and I’ve gotten an enconde issues once or twice, I solve the enconde issues in the JS, not in PHP.
Sometimes, I return numbers from PHP echo, and I use switch statement in JS to make what I want depending of the returned number, it solves some problems too.
I know I didn’t solve your problem, instead I’m trying to get alternative ways, but lemme known if it helps
Related Posts:
- admin-ajax.php responding with 0
- Page Reloads Before AJAX Request Finishes
- How to test nonce with AJAX – Plugin development
- How to send Ajax request from my plugin in admin dashboard?
- How to use wp_send_json() and output the value with ajax?
- Settings API form – submit with AJAX
- Post form – AJAX won’t upload featured image – Plugin development
- Do I require the use of nonce?
- Gutenberg Blocks doesn’t render correctly when using do_blocks
- WordPress Ajax always returns a 404 error
- simple wordpress ajax plugin not working when not logged in
- Audio Player not loading when the content is loaded through Ajax, MediaElement.js no applied
- Ajax call doesn’t work in frontend but it’s working in backend (when I’m logged in)
- Data fetch and delete by ajax request
- Handling an Ajax form submit
- Custom WordPress+PHP+MYSQL+AJAX form, submit event not captured by Javascript, but does POST data to the DB
- Problem with WordPress Ajax form
- Click loads template via ajax
- Display notification only once
- Access/update database with jQuery
- How to display something in a div when the user clicks on a text in another div – no page refresh [closed]
- How to set a custom path, for ajax image upload folder in admin?
- How to speed up admin-ajax.php in wordpress
- Colorbox ajax loading of outside HTML content works perfect on localhost but not on server
- How to make custom total price reactive in navigation
- How to prevent those PHP variables from being cached on WordPress?
- Ajax return code 400
- Ajax not working es expected (Returns 0)
- Create onClick Event to Re-load a Widget
- How to select the contents in the text view textrea in wp_editor?
- Creating a Multi-Level Associative Object Using AJAX
- WordPress ajax doesn’t display object method on jQuery .change() function
- Status 400 for AJAX POST Request with admin-ajax.php
- Ajax random number always the same
- Image upload via FormData API and AJAX is not working ($_FILES always empty)
- adjust section according to country?
- How to add a do_action on refreshing of WP customizer?
- Setting value of session with Ajax not working
- How to add a Custom Mailchimp AJAX Newsletter Subscribe Form
- Fancybox type popup window that’s not an iframe
- how to update and display an option without reloading the page
- WordPress Ajax Call inserting data but success response false
- admin-ajax Firing Error 400 When Logged In
- Making an AJAX call to refresh a table
- Using data sent via AJAX in multiple functions on a WP plugin
- Problem with AJAX in wordpress plugin
- wordpress admin plugin menu custom css
- Load Posts on Click via Ajax into a DIV
- AJAX wp_insert_user WORKS but responds with “The site is not enabled”
- How to Change CSS Colors from Custom Plugin Settings Page
- Passing the name of selected color from the custom component to `render_callback`
- Any ideas why I am getting “I’m getting “wp-admin/admin-ajax.php 401 (Unauthorized)”
- Why i can’t get custom fields value or post ID via Ajax?
- Cannot access $wpdb, comes back NULL
- Submitting a form, using Ajax, to run a SQL Select query based on user input from the form
- Incrementing PHP variable onclick to display posts by month
- Accessing an API with jQuery and AJAX
- Ajaxurl suddenly not defined
- Execute Jquery when a specific page in my plugin is loading
- calling admin-ajax.php from admin-ajax.php
- Ajax URLs without #!, how to prevent falling into single.php on load or reload?
- WordPress cascading dropdown selection search based on Parent Page & Child Page
- Display WordPress search results based on the selected Sub-Category
- Ajax on the Administration Side of plugin – wp_localize_script – how to pass value from JQuery to PHP function in class?
- Load more posts using AJAX based on posts inside WP_Query
- Creating a POP Alert
- How can i find wrong word in search box and replace with correct word
- How to use wp_ajax_set_post_thumbnail?
- How can I get my WordPress plugin to receive data and relay it in an ajax/php request to a remote server that requires authentication?
- Submit remote form to wordpress REST API and save data to custom post type
- 400 bad request admin-ajax file upload
- register dependency css and js inside a plugin class
- Filtering custom posts by using checkboxes for taxonomy in an ajax loop always gives server 500 error
- Cannot successfully execute AJAX script to call function.php specific function. Using XAMPP localhost to test
- Input field duplicates on form submit by jQuery
- How to echo a PHP code into WooCommerce variation product?
- How to call a function from functions.php with ajax?
- ajax polling with admin-ajax.php
- Ajax in a class instantiated via shortcode
- number of posts with “Load More”
- Ajax wordpress function showing source code in alert and not value of input field?
- How to send Ajax Call from frontend without using wp_localize_script in Theme
- defined (‘ABSPATH’) false after AJAX post to other PHP-file
- How to load WP_Editor JS files manually (with AJAX)?
- A javascript function that simply runs a php function on the plugin
- Retrieve $_POST data to send to javascript without using localize script
- How to limit each front-end user to view just his own uploaded files on Amazon S3?
- How to use Amazon Elastic Transcoder from WordPress using AWS SDK for PHP?
- 500 (Internal Server Error) of external php file
- Problems with plugin that fetches data from database with ajax
- Why this plugin is not working?
- Dynamic Gallery
- Execute PHP code in Javascript onclick
- Pass a PHP variable (loop-audio.php) to jQuery function (js/script.js)
- Remove Woocommerce product from cart with ajax/fetch
- ajax problems on loading page [closed]
- WooCommerce Modal Fly cart on add to cart – With AJAX
- How can I use AJAX in child theme template?
- I got this error POST https://localhost/meraboilerwp/[object%20Object] 404 (Not Found)
- Add Imports to Existing WordPress Import Map