How to have multiple responses in same ajax call?
-
Hello,
I am making an ajax call with some parameters in wordpress
$.ajax({ type : 'POST', dataType : 'html', url: '<?php echo admin_url('admin-ajax.php'); ?>', data : { 'yearArr' : yearArr, 'transmissionArr' : transmissionArr, 'doorsArr' : doorsArr, 'cylindersArr': cylindersArr, 'drivetrainArr' : drivetrainArr, 'certifiedArr' : certifiedArr, 'fueltypeArr' : fuelTypeArr, 'bodystyleArr' : bodystyleArr, 'makeVal' : makeVal, 'modelVal' : modelVal, 'bodytypeVal' : bodyTypeVal, 'minpriceVal' : minPrice, 'maxpriceVal' : maxPrice, 'minmileageVal' : minMileage, 'maxmileageVal' : maxMileage, 'exteriorcolorVal' : exteriorColor, 'interiorcolorVal' : interiorColor, 'sortbydesktopVal' : sortbyDesktop, 'sortbymobileVal' : sortbyMobile, 'searchbarVal' : searchBar, 'action' : 'Get_Ajax_Filters', }, success : function(result){ $('element1').html(result1) $('element2').html(result2) }, error : function(error) { alert('something went wrong please try again or refresh the page') $('.inventory-products__overlay').css('display','none'); } })
I made a function in functions.php file. the function is running wp query which i can output on frontend in success call.
What i want is to modify the function in a way that it returns two array or some sort of data by which i can show the selected filters in #results element and the listings returned from wp_query in #listings element
IDK how i can do this. I can not send multiple actions to function.php, and the result parameter in success function also returning the whole content so i’m little confused what to do now.I will really apperaciate if you can help.
Regards
Junaid
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘How to have multiple responses in same ajax call?’ is closed to new replies.