Skip to content

Instantly share code, notes, and snippets.

@nikolab
Created December 18, 2019 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save nikolab/08b57404ef2510943626dce610e53268 to your computer and use it in GitHub Desktop.
Save nikolab/08b57404ef2510943626dce610e53268 to your computer and use it in GitHub Desktop.
Get person content - Ajax
//team showcase
$(document).unbind("click").on("click", ".tshowcase-box", function (event) {
$this = $(this);
$this.siblings().removeClass('active');
$('.person-content-wrap').hide();
$this.toggleClass('active');
var url = $(this).find('a').attr('href'); //get url
var new_url = url.substring(0, url.indexOf(' ')); //substirng url
//get person content
$.ajax({
url: new_url, //Pass URL here
type: "GET", //Also use GET method
beforeSend: function() {
if($this.hasClass('active')) {
$('.tshowcase-box.active').append('<div class="person-content-wrap"><p class="loading-team-content">Loading...</p></div>');
}
},
success: function(data) {
var content = $(data).find('.tscontent').html();
// console.log(content);
$('.person-content-wrap').empty();
$('.person-content-wrap').append(content);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment