In short, you should use response.data.messages
.
And that’s because wp_send_json_success()
will send a JSON response (an object) with the property data
set to whatever that you passed to the function.
wp_send_json_success( 123 );
// In JS, response.data would be an integer. I.e. response.data = 123
wp_send_json_success( array( 'foo' => 'bar' ) );
// In JS, response.data would be an object. So response.data.foo = 'bar'
Related Posts:
- ASP.NET MVC controller actions that return JSON or partial html
- How to cache json with wp-super cache
- Why use wp_send_json() over echo json_encode()?
- WordPress function that makes HTML safe to be sent via AJAX request
- WP REST API route request explain
- How to use wp_send_json_error?
- Most performant way of fetching remote API data?
- json encode not work in wordpress
- Ajax store response json in variables
- How do I query posts by a sub value with the API?
- Cache wp-json/posts without a plugin?
- merge wp rest api query to get posts per category does not work
- Retrieve JSON file from JS trough php
- Upload data from weather station to WordPress Website
- Sql formatting for post data within function
- How can I wp_send_json data?
- Full Front End, AJAX comment system and comment reply script
- Send checkbox status with Ajax / JSON and save it
- Chained ajax call, second call returns 0
- Display full WordPress post under search form using AJAX
- Can I use application/json content type in WordPress
- Using wp_send_json_success instead of $result[‘message’], die, etc
- AJAX POST Value not being returned – WordPress – AutoTrader API
- Ajax call works for logged in users and returns “Bad Request” for guests [duplicate]
- How to inject data content from external json into a modal, using UIkit?
- how to correctly use json_encode with ajax
- WorddPress website admin part not working correctly – I think ajax/json issue
- 403 error for ajax POST request
- Ajax WordPress pass post URLs
- How to populate data from JSON using AJAX in TypeScript? [closed]
- WordPress Ajax JSON success return no being recognized
- Ajax contact form returnig 0
- AJAX Call in Plugin Returns More than JSON
- Usage of wp_send_json_success and wp_redirect at the same time
- Bad Request 400… jQuery ajax post of json data to wordpress admin-ajax.php
- JSON parsing error syntax error unexpected end of input
- Can JavaScript connect with MySQL?
- Get Previous & Next posts by Post ID
- ajax – why multiple calls to wp_create_nonce() return same value?
- AJAX request on the frontend always returns 0 if user is not admin
- Admin Notification after save_post, when ajax saving in gutenberg
- Using ajax on categories and wordpress loops
- Cannot load admin-ajax.php. No access-control allow origin*
- Initialize JS with an ajax loaded ACF form
- AJAX returns response 0
- Nonces and Ajax request to REST API and verification
- Vue.js + AJAX Shortcode
- wp_ajax action is not running
- WordPress AJAX calls not detecting language properly?
- AJAX issue – Uncaught SyntaxError when processing Zip File
- wp_verify_nonce doesn’t return true on server when it matches the nonce
- update_user_meta doesn’t work with AJAX
- wp-admin AJAX with Fetch API is done without user
- Load ajax if is_home()
- WordPress Admin AJAX Serialize
- Why a strange discrepency between get_current_user_id() when using AJAX versus output of document.cookie?
- Loading post template that contains a nested loop with ajax
- Long Polling: Stuck in while loop
- Show Post Content with AJAX
- Code run fast on a cronjob but slow with a do_action or ajax call
- update_post_meta using ajax
- Ajax comment form submit on frontpage alerts success but no insertion
- Wp mail does not work when Ajaxed to
- MySQL select query with ajax
- Exposing data using a custom WordPress API
- Use WP admin AJAX url to hide API key
- ajax form is returning the dreaded “[HTTP/1.1 400 Bad Request” and a zero
- Making POST request with AJAX returns a 400 error (without jQuery)
- Load image src through Ajax by ID?
- Using get_theme_mod in php ajax form doesn’t work
- PHP session when called wp_ajax_nopriv
- What exactly does ‘authenticated’ mean for wp_ajax_nopriv?
- How to make image in TinyMCE clickable
- How to use Jeditable plugin with admin-ajax.php?
- WordPress Ajax Not Firing
- Disabling ajax code that does a POST request that ends in a 400 error code
- Is it good practice to use REST API in wp-admin plugin page? [closed]
- How to prevent my external API call from being called by anyone but me (my site)
- get a bad request 400 on my ajax-admin.php file
- Registration form AJAX check for existing username (simple version)
- How to check Ajax request only when i opened the Notifications list?
- Trigger action via button
- Syntax error on query_vars while handling with Jquery
- Want to send ajax request in wordpress to a custom file in plugin
- How to send the checkbox value to email
- wp_send_json erase last value
- Ajax take too long to return code
- problem when adding wp_editor with ajax [duplicate]
- Get wp-load.php PATH with wp_localize_script and JavaScript for plugin
- Ajax Form seems to post, but does not return
- Ajax request to admin-ajax.php and window.location.href
- Why can wordpress not find the actions I add in my constructor?
- delete attachment for one post without deleting actual attachment post
- Memberpress isn’t cooperating with WooCommerce
- where does my function output from load-* go?
- Adding a time stamp on post view
- WordPress ajax requst returns zero
- WordPress blocking polling request when signed into Admin
- Pass a PHP variable (loop-audio.php) to jQuery function (js/script.js)
- wordpress ajax bad request 400