I am utilizing Elementor Professional as my web page builder. I am attempting to create a Job Publish filter utilizing Elementor kinds. Challenge is once I echo and return an Object sort from the features.php file to the JS file. It offers out an Inside Server Error 500. I wish to understand how I can cross the entire publish object as a substitute of sending Title, excerpt, picture individually.
JS code
jQuery(perform($){
$('#jobs_filter_form').submit(perform(){
filter = $('#jobs_filter_form');
let key phrases = $('#form-field-job_keywords').val();
let location = $('#form-field-job_location').val();
let class = $('#form-field-job_category').val();
$.ajax({
url:'http://localhost/placementpro/wp-admin/admin-ajax.php',
knowledge:{
'motion': 'filter_jobs',
'key phrases': key phrases,
'location': location,
'class': class,
},
sort:'POST',
beforeSend:perform(xhr){
filter.discover('button').textual content('Processing...'); // altering the button label
},
success:perform(knowledge){
filter.discover('button').textual content('Apply filter'); // altering the button label again
$('#filtered_jobs').html(knowledge);
},
});
return false;
});
});
PHP code
add_action('wp_ajax_filter_jobs', 'filter_jobs_function');
add_action('wp_ajax_nopriv_filter_jobs', 'filter_jobs_function');
perform filter_jobs_function(){
$key phrases = $_POST['keywords'];
$location = $_POST['location'];
$class = $_POST['category'];
$args = array(
'post_type' => 'kuwjr_job',
'cache_results' => false,
'update_post_meta_cache' => false,
'update_post_term_cache' => false,
'fields' => 'all',
'post_status' => 'publish',
'posts_per_page' => 12,
'orderby' => 'date',
'order' => 'DESC',
's' => $key phrases,
'meta_query' => array(
array(
'key' => 'location',
'worth' => $location,
),
),
'tax_query' => array(
array(
'taxonomy' => 'job-category',
'phrases' => $class,
'subject' => 'title',
),
),
);
$question = new WP_Query( $args );
if( $query->have_posts() ):
whereas( $query->have_posts() ): $query->the_post();
echo $query->publish;
endwhile;
wp_reset_postdata();
else :
echo 'No posts discovered';
endif;
die();
}