I am trying to use jQuery ajax to call in a project page.
Assume the xhr variable contains the correct string to the webpage (target page). I have prevented the page as mobile viewport will not load the ajax request.
$('a.project__block').on('click', function(e){
var $el = $(this),
viewportWidth = $(window).width();
if (viewportWidth >= 768){
e.preventDefault();
var xhr = $.get($(e.currentTarget).data('href'));
xhr
.done(open_overlay)
.fail(function(){
alert('Could Not Connect, please report to admin!');
});
}
});
function open_overlay(data){
close_overlay_window();
$('body').addClass('active--overlay').append(data);
supporting_code();
}
function close_overlay_window(){
$('#bravedogers').remove();
$('body').removeClass('active--overlay');
}
function supporting_code(){
$('.ajax__close__link').on('click', close_overlay_window);
}
function remove__active__classes(){
// Is the overlay active? If not dont close!
if (viewportWidth < 768 && $('body').hasClass('active--overlay')){
close_overlay_window();
}
}
I want to target the specific id which remains constant in all the project pages, e.g:
<div id="wrapper__container"></div>
At present I am getting this error:
Ideally can in addition see modernizr being loaded in which causes my page to crash.
Any ideas?