Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.
        jQuery.ajax({
            type: "POST",
            url:"wp-admin/admin-ajax.php",
            data:'action=nafham_list_cats_selection&selection_id=' + $selection_id,
            success:function(results){
                jQuery(".semester_selection").empty();
                jQuery(".semester_selection").prop('disabled', false);
                jQuery(".semester_selection").append(results);
            }
        })

This is the ajax call I'ms ending, the following is the function that sends the data:

function nafham_list_cats_selection() {
    if(isset($_POST['selection_id'])){ 
        nafham_get_listed_cats($_POST['selection_id']);

    }
}

How can I let the function outputs two values so that I can use

success:function(results1, results2){
share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Instead of passing two parameters to function you can pass the array of two values like this :

$results['args1'] = "value1";
$results['args2'] = "value2";

echo json_encode($results);

and then get it in success function like this :

success:function(results){
jQuery(".semester_selection1").append(results.args1); // This appends value1
jQuery(".semester_selection2").append(results.args2); // This appends value2
}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.