Have you tried returning an array instead?
wp_send_json($an_array_of_your_vals);
And then parse the array in the success function?
success: function( data ) {
var obj = jQuery.parseJSON(data);
if( obj.arg_1 ) {
$('selector').append( obj.content );
} else if( obj.arg_2 ) {
$('other_selector').append( obj.content );
}
}
Related Posts:
- How to Dynamically Load Content Into Body of Bootstrap Modal Window?
- url – ajax loaded but no JS
- My javascript is returning this error: $.ajax is not a function
- Can’t get a JSON object in response to an Ajax request with wp_ajax
- Infinite scroll / lazy loading with NextGen Gallery [closed]
- Ajax call does not activate callback function
- Trying to get single posts to load on the front page via ajax
- Ajax not firing properly using Firefox, but works in Chrome
- How to Use JSON With AJAX?
- Using wp_ajax and wp_ajax_nopriv hooks
- wp_ajax unauthenticated and authenticated
- WordPress ajax function parameter value not being passed
- WordPress customizer refresh screen after save
- Loading posts via AJAX in a hidden div with updated URL?
- Correct way to write jQuery functions in WordPress
- WooCommerce Ajax Cart Update Stopped Working
- Trouble with WordPress Ajax Login System – 302
- videopress videos are not displayed when loading the content with ajax in a lightbox
- Callback After WordPress Customizer Complete Loading
- Ajax Validation for reCaptcha
- Properly embed javascript into WP (using function.php) – doesn’t work?
- Custom AJAX form not working async
- AJAX Success Function using JS substr() fails in WP 4.1 vs 4.0
- Is there some jQuery conflict here?
- Ajax page load in wordpress the right way?
- Orderby post__in Not Working Correctly?
- Get ajaxForm response value
- Retrieve customizer value using ajax or customizer api and print the value in theme
- Displaying contents of a tab
- Widget won’t work due to old JavaScript? Any ideas how to make it work? [closed]
- What does [object Object] mean? (JavaScript)
- Why does my JavaScript code receive a “No ‘Access-Control-Allow-Origin’ header is present on the requested resource” error, while Postman does not?
- JavaScript error (Uncaught SyntaxError: Unexpected end of input)
- JavaScript error (Uncaught SyntaxError: Unexpected end of input)
- jQuery Ajax error handling, show custom exception messages
- ajax jquery simple get request
- Javascript Runtime error: $ is undefined
- jQuery AJAX cross domain
- jQuery AJAX submit form
- Ajax TypeError: $.POST is not a function
- Javascript TypeError: Cannot read property ‘indexOf’ of undefined
- jQuery – Illegal invocation
- How to call a webservice method from an html page [javascript] with out refresh the page
- How can I remove all CSS classes using jQuery/JavaScript?
- jQuery ajax error function
- AJAX nonce with check_ajax_referer()
- jQuery UI Datepicker not working
- AJAX call returns 0
- Draggable item in custom gutenberg block
- Drag and drop multiple file upload using Ajax WordPress
- AJAX post into pop-up div
- Appending anchor tag to next post
- Registration e-mail check with AJAX
- Updating User Profile with AJAX not working
- Display notification only once
- Auto Load New Posts
- wp_ajax() question.. not using wp_enqueue_script?
- Showing Author Information and Latest Post by author in lightbox when clicked on the name of the author
- Colorbox ajax loading of outside HTML content works perfect on localhost but not on server
- WP Admin missing icons, numerous JavaScript errors, but only when SCRIPT_DEBUG is false
- wpColorPicker: How update colors on input value update?
- Ajax, Permalinks and post_thumbnail
- How to embed JS data viz in a simple WordPress website
- Rhyzz Repeatable-fields javascript in php and wordpress
- First Attempt at AJAX and it keeps getting Canceled. Can’t Get Results to Show
- WordPress Ajax Call inserting data but success response false
- window.onload wont execute in wordpress
- Display posts from another site using REST API in an asynchronous manner
- Why does my jQuery AJAX return 0?
- Why doesn’t jQuery use $, and how can I get it do so (GLOBALLY)?
- Simplest ajax form not working when it should
- I have an old version of jQuery showing up. How do I figure out where it is coming from?
- How do I include javascript/jquery image resizing with wordpress?
- Search input area autogrow – how?
- Loading dynamic content with AJAX breaking jQuery
- How to change the text of the “You are about to permanently delete these items…” alert message when deleting media from the media library?
- why is my wordpress Jquery-Ajax call not working?
- Unable to get my javascript to work on my website – what am I doing wrong?
- Multiple Media uploader output to input
- Can’t add classes using jQuery from a JSON string with get_body_class()
- Ajax call through admin-ajax.php returns 404 error
- Using WP functions inside javascript
- How to add external remote JS source to Gravity Forms?
- Screen Options JavaScript Code
- Why is ajax working on one server and not the next?
- Connect Agile Carousel to WordPress AJAX
- jQuery forms & updating info
- WordPress cascading dropdown selection search based on Parent Page & Child Page
- Running JavaScript after using WooCommerce Filter Plugin
- Defer Parsing of Scripts
- JavaScript code do not works on online server
- jQuery not working for media uploader
- comment-reply.js disables any other form javascript
- Uncaught TypeError: undefined is not a function (shortcode-box)
- Variable not being returned from Ajax Javascript (though javascript receives it)
- How to respond with WP_Ajax_Response();
- Trying to get fittext to work in WordPress
- How to Run a jQuery Script after a Javascript Script has Finished in WordPress
- Load css classes after using ajax calls
- WordPress Ajax send response on every iteration of a loop