Unable to parse JSON response from wp_send_json_success [closed]

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'