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
- JQuery UI Autocomplete/Autosuggest WordPress
- How to show custom fields in modal in category page
- JSON parsing error syntax error unexpected end of input
- PHP “php://input” vs $_POST
- Google Maps API throws “Uncaught ReferenceError: google is not defined” only when using AJAX
- jQuery AJAX cross domain
- Jquery Ajax Posting JSON to webservice
- Basic example of using .ajax() with JSONP?
- TypeError: $.ajax(…) is not a function?
- React Js: Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0
- Can JavaScript connect with MySQL?
- Access-Control-Allow-Origin error sending a jQuery Post to Google API’s
- Access-Control-Allow-Origin error sending a jQuery Post to Google API’s
- How to solve the error “SCRIPT7002: XMLHttpRequest: Network Error 0x80070005, Access is denied.” in IE
- JSON.parse() not working
- Show spinner GIF during an $http request in AngularJS?
- Refresh HTML Page in Browser Automatically on Timer – Every 15 Min
- SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
- JavaScript implementation of Gzip
- jQuery: Performing synchronous AJAX requests
- jQuery’s .on() method combined with the submit event
- “NS_ERROR_DOM_BAD_URI: Access to restricted URI denied”
- Ajax takes 10x as long as it should/could
- How to check if I am in admin-ajax.php?
- Best way to end WordPress ajax request and why?
- How to load wp_editor() through AJAX/jQuery
- Load minimum WordPress environment
- Why use admin-ajax.php and how does it work?
- How to get a unique nonce for each Ajax request?
- Open a Thickbox with content trough AJAX
- Initialize TinyMCE editor / visual editor after AJAX insert
- Why not register shortcodes if is_admin dashboard?
- WordPress AJAX with Axios
- Why is die() used at the end of function that handles an Ajax request?
- Why might a plugin’s ‘do_shortcode’ not work in an AJAX request?
- Making my AJAX powered WordPress Crawlable
- Is there a JavaScript API? How to access public and private data in JS?
- Get Previous & Next posts by Post ID
- failed to load wp-admin/admin-ajax.php
- Using Backbone with the WordPress AJAX API
- Using Ajax with a Class file
- Ajax in a settings page (update_option is undefined)
- How to pass data parameter to ajax action function handler
- WordPress Ajax Data Security
- Allowing admin-ajax.php to receive “application/json” instead of “x-www-form-urlencoded”
- Displaying PHP Errors from admin-ajax.php
- wp_set_auth_cookie() doesn’t work in Ajax call
- gettext does not translate when called in ajax
- Execute one AJAX request after another AJAX request finished
- Can’t get a JSON object in response to an Ajax request with wp_ajax
- WP-AJAX vs WP REST API: What to use for requests to the website from outside?
- Ajax and autocomplete
- How to add to cart via AJAX Woocommerce [closed]
- Nonces and Cache
- SSL breaks customizer: page isn’t returned from ajax
- Why is a 500 error generated by admin-ajax.php not going into the Apache error log?
- Are ‘wp_ajax’ and ‘wp_ajax_nopriv’ exclusive to authenticated and non-authenticated users?
- How to HTML5 FormData Ajax
- admin-ajax.php vs Custom Page Template for Ajax Requests
- How to override WP_DEBUG for Ajax responses?
- Stop admin-ajax?
- redirect out of wp-admin, without losing admin-ajax.php
- Call to undefined function add_action()
- Is it safe to assume that a nonce may be validated more than once?
- Including WordPress in RESTful API