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]
- jQuery selectable() function won’t work in wordpress
- oEmbed Video in Modal
- No Object Properties sending form through AJAX
- Redirect wp_dropdown_pages() to an AJax request?
- Multiple Media uploader output to input
- 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
- click event to unhide something after ajax not firing
- WordPress Insert not working with ajax
- Search query with Ajax
- WP AJAX API with JS file
- how to use wp_editor() here am getting empty result
- admin ajax php success returns 0
- Accessing an API with jQuery and AJAX
- Manipulate retrieved ajax data in php
- Using WP functions inside javascript
- How to add external remote JS source to Gravity Forms?
- Using Jquery submit with ajax request
- Blur.js with WordPress – Enqueued, but server not finding file
- Is it OK combined wp-include js, jquery, css? [closed]
- Including Older Version of jQuery for IE7/IE8
- Parse wordpress blog data using json api and ajax
- Screen Options JavaScript Code
- Why is ajax working on one server and not the next?
- Problem adding MP3 attachments to a jPlayer playlist
- How to use wp_update_post with ajax on frontend
- How To Include JavaScript Files Only In Single Posts?
- wordpress before or after javascript problem
- Using jQuery .after inside loop
- Getting jQuery AJAX to work in WordPress (getting -1)
- problems with jquery external rss feed integration
- Converting a working AJAX form to work with WordPress
- Connect Agile Carousel to WordPress AJAX
- WordPress Front-End Theme Editor
- Change Query Arguments (filter) with jQuery/Ajax or PHP?
- Theme has superfish – how to add supersubs?
- Jquery not working
- AJAX calendar navigation returns -1
- A carousel slideshow plugin in JavaScript
- Which hook to use when adding ajax to viewer-facing side?
- my example with ajax doesn’t work
- Best way to add some custom javascript using jquery to a child theme
- JS behavior differs depending on page tree [closed]
- jQuery forms & updating info
- How to display contact form 7 form in vanilla js without jquery in frontend
- WordPress cascading dropdown selection search based on Parent Page & Child Page
- Uncaught TypeError: Cannot read properties of undefined (reading ‘message’) [closed]
- Tracking Visitor LatLng with WordPress using JS, PHP. How to put data which was extract using JS into DB
- Jquery POST Ajax Return null data in wordpress
- javascript onClick update user_meta from jquery.ajax
- Running JavaScript after using WooCommerce Filter Plugin
- Admin-ajax.php 404 error
- How to pass values from one function to the other using an array variable
- Ajax Call not Working in Plugin
- Ajax sometimes work and sometimes just don’t work
- JS working when used normally but not in wordpress
- How to use wp_ajax_set_post_thumbnail?
- WordPress live search and filter
- Update $wpdb query with AJAX
- I am trying to Implement a Code that is Working in my previous page but not working in WordPress for some reason
- React to AJAX adding to the page
- AJAX to add to cart multiple products woocommerce
- How to use $ with externally loaded javascript
- Add JQuery As Code Snippet
- Theme customisation – how to store javascript externally when it utilises php variables?
- Getting click on item to open closest relevant element (popup) with jQuery
- Download doccument on server rather than clients browser
- Form validation before submitting
- How to make JQuery load on top of head tag before everything