+let url_admin:string = window.location.origin + '/wp/wp-admin/admin-ajax.php';
+ * Retrieve the expert custom post type matching the parameter
+ * The SQL query is done in `lib/posts.php` and perform a simple WP_Query
+ * 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
+const getExpert = ( service:number, sector:number, office:number ) => {
+ // Fallback for IE versions that don't support window.location
+ if ( !window.location.origin ) {
+ url_admin = window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port: '');
+ // Prepare the data for the request
+ 'action' : 'load_expert',
+ // Send the AJAX request that will be handled by "lib/posts.php"
+ .done( function( html ) {
+ // Add the new expert markup in the overlay
+ $expert_container.append( html );
+ $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 );