// URL for the WP Adminleturl_admin:string=window.location.origin+'/wp/wp-admin/admin-ajax.php';/** * getExpert * Retrieve the expert custom post type matching the parameter * The SQL query is done in `lib/posts.php` and perform a simple WP_Query * to get 1 post * Note: only 1 parameter at the time will be used because when the user * selects an option in a list on the site, the other filter lists reset * @param service * @param sector * @param office */constgetExpert=(service:number,sector:number,office:number)=>{// Fallback for IE versions that don't support window.locationif(!window.location.origin){url_admin=window.location.protocol+'//'+window.location.hostname+(window.location.port?':'+window.location.port:'');}// Prepare the data for the requestletdata:Object={'action':'load_expert','service':service,'sector':sector,'office':office};// Send the AJAX request that will be handled by "lib/posts.php"$.ajax({url:url_admin,type:'POST',data:data}).done(function(html){// Add the new expert markup in the overlay$expert_container.append(html);// Hide the loader$loader.fadeOut(150,function(){// Once the loader is hidden, show the new expert$expert_container.find('.expert-overlay-preview').fadeIn(500);});}).fail(function(jqXHR,textStatus,errorThrown){console.log('textStatus = '+textStatus);console.log('errorThrown = '+errorThrown);});
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.