ajax multipli Values

i tryed to return multiple Values from an Ajax Call,

Is it posible to do that? or could I use an Array? Or should i do for every Call a own Function?

My Function: “here i will do one ore more Database querys”

function rob_ajax_vorlage() {
global $wpdb;
$a = “100”;
echo $a;
$b = “200”; //second value that doesen work jet
echo $b; //second value that doesen work jet
wp_die(); // just to be safe
add_action( ‘wp_ajax_rob_ajax_vorlage_approal_action’, ‘rob_ajax_vorlage’ );
add_action( ‘wp_ajax_nopriv_rob_ajax_vorlage_approal_action’, ‘rob_ajax_vorlage’ );

And my Ajax call

jQuery(document).ready(function($) {
$( ‘#rob-wp-ajax-vorlage-button’ ).click( function() {
var abc = $( ‘#abc’ ).val();
method: “POST”,
url: ajaxurl,
data: { ‘action’: ‘rob_ajax_vorlage_approal_action’, ‘abc’: abc, }
.done(function( data ) {
console.log(‘Successful AJAX Call! /// Return Data: ‘ + data);
.fail(function( data ) {
console.log(‘Failed AJAX Call 🙁 /// Return Data: ‘ + data);

Im A Beginner so sorry if i asked something crazy.

so it would be grade if someone could help me to use return two values.

I would to create a PDF with some Data from database and i think ajax is the best way to do that?

Thank you


Read more here:: ajax multipli Values

Leave a Reply

Your email address will not be published. Required fields are marked *