Note that the action
should be inside the data
key. In your post request there is no key named as action
therefore, the callback function is never being called.
Consider this example:-
jQuery.ajax({
type:"POST",
url: "/wp-admin/admin-ajax.php",
data: {
action: "my_test_action",
form_data : newFormChange
},
success: function (data) {
console.log(data);
}
});
Also Note: Never use relative Ajax URL like /wp-admin/admin-ajax.php
. You can use wp_localize_script()
. See these examples
Related Posts:
- JSON parsing error syntax error unexpected end of input
- jQuery Ajax error handling, show custom exception messages
- How to send multiple data fields via Ajax?
- Jquery Ajax Posting JSON to webservice
- Ajax TypeError: $.POST is not a function
- How to fix the ‘Missing required request header. Must specify one of: origin,x-requested-with’ Ajax Error
- What’s the point of the X-Requested-With header?
- How to get a cross-origin resource sharing (CORS) post request working
- jQuery – Illegal invocation
- jQuery ajax error function
- WordPress AJAX File Upload – FrontEnd
- Can’t get a JSON object in response to an Ajax request with wp_ajax
- AJAX nonce with check_ajax_referer()
- Creating Ajax backend for Specialised Page Template? Should admin-ajax.php be used?
- Infinite scroll / lazy loading with NextGen Gallery [closed]
- wp_mail script with jQuery post
- jQuery and AJAX Not working with Select Form Element
- jquery & ajax getting data to php in wordpress
- AJAX returns response 0
- Passing a varible from jQuery to PHP
- AJAX post into pop-up div
- Bind to WPSetAsThumbnail
- Appending anchor tag to next post
- How to Use JSON With AJAX?
- wp_localize_script, variable is not defined in jquery
- Using wp_ajax and wp_ajax_nopriv hooks
- WP REST return value to error function from Request
- Registration e-mail check with AJAX
- Updating User Profile with AJAX not working
- Auto Load New Posts
- wp_ajax() question.. not using wp_enqueue_script?
- wp_ajax unauthenticated and authenticated
- Showing Author Information and Latest Post by author in lightbox when clicked on the name of the author
- WordPress Ajax not function as I expect… what’s wrong?
- Accept AJAX call with serialized form data
- Is there a restriction in WP on the use of jQuery load function?
- Loading posts via AJAX in a hidden div with updated URL?
- Jquery not showing in homepage
- Ajax not posting form data to query in PHP function
- jQuery Ajax returning correct Response, but after redirect to 404 Error
- How to get those data using with ajax json?
- Front-end Ajax File Upload
- Display data on same page as form without refresh
- gravity forms jQuery.load into modal [closed]
- Error when posting comment form: The error is TypeError: e[h] is not a function
- jQuery ajax call throws an HTTP 302
- Ajax, Permalinks and post_thumbnail
- WooCommerce Ajax Cart Update Stopped Working
- WordPress AJAX Load More function duplicating a post
- Advanced Ajax Page Loader (AAPL) blocks resources
- First Attempt at AJAX and it keeps getting Canceled. Can’t Get Results to Show
- videopress videos are not displayed when loading the content with ajax in a lightbox
- How to return multiple arguments from AJAX callback function
- Display posts from another site using REST API in an asynchronous manner
- Why use admin-ajax.php when loading pages through AJAX?
- WP Rest Api / Ajax POST not working when not logged in
- Why does my jQuery AJAX return 0?
- Simplest ajax form not working when it should
- Ajax Validation for reCaptcha
- Sorting WP Auctions by date/price?
- Loading dynamic content with AJAX breaking jQuery
- why is my wordpress Jquery-Ajax call not working?
- fill form fields with ajax response
- Adding custom cart price with Ajax in wordpress
- Can’t add classes using jQuery from a JSON string with get_body_class()
- Null/undefined return in WordPress AJAX request
- Ajax call through admin-ajax.php returns 404 error
- AJAX Success Function using JS substr() fails in WP 4.1 vs 4.0
- Manipulate retrieved ajax data in php
- Using Jquery submit with ajax request
- Why is ajax working on one server and not the next?
- How to use wp_update_post with ajax on frontend
- Converting a working AJAX form to work with WordPress
- Connect Agile Carousel to WordPress AJAX
- WordPress Front-End Theme Editor
- Ajax page load in wordpress the right way?
- jQuery forms & updating info
- Orderby post__in Not Working Correctly?
- wordpress ajax upload media not working
- Reload selected post in multiple post query with ajax
- jQuery.post() calling function with parameter
- $_POST empty in using new php file added to theme
- Passing variable data from external jQuery file to options.php
- How to specify url for ajax call in wordpress plugin
- Possibility of creating a folder in the wordpress root install and installing a file there, all via plugin?
- Displaying contents of a tab
- owl carousel not working after ajax load [duplicate]
- Call admin ajax using absolute url? Relative URL breaks (frontend ajax)
- Load more button
- Ajax autocomplete based on usercode
- Variable not being returned from Ajax Javascript (though javascript receives it)
- Page keeps refreshing with Ajax form
- jQuery AJAX add json2 dependency?
- How to respond with WP_Ajax_Response();
- Convert WordPress SACK code to new admin-ajax
- Get selected value with PHP and jQuery
- Ajax request with jQuery without WP_ajax
- Ajax Query returns zero
- Dynamically populate Cascading Dropdown from MySQL using JQuery/AJAX [closed]
- How to combine jQuery in-place editor with $wpdb->update