0

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:

enter image description here

Ideally can in addition see modernizr being loaded in which causes my page to crash.

Any ideas?

Neil
  • 971
  • 2
  • 12
  • 33
  • That's a warning, not an error. Where is it thrown? – isherwood Sep 29 '14 at 14:19
  • The ajax complete but dumps the whole html page, not the specific div. I am referring to the meta tags the lot. The error is thrown in chrome dev tools – Neil Sep 29 '14 at 14:29
  • Let me rephrase. On what line, exactly, is the warning thrown? (Click the link you're provided.) – isherwood Sep 29 '14 at 15:33
  • it appears to be a google map script being loaded via google apis. It is probably being thrown off due to the scripts being loaded twice. – Neil Sep 29 '14 at 16:05

1 Answers1

0

Is this what you're trying to do? Append just the wrapper?

function open_overlay(data){
    close_overlay_window();
    var container = $(data).find('#wrapper__container');
    $('body').addClass('active--overlay').append(container);
    supporting_code();
}

I would see if that makes your warning go away. Just looking at the warning, it looks like Google Maps isn't happy about something.

Clayton Leis
  • 1,288
  • 9
  • 20
  • sorry no, I am looking to get the a specific id of html code, rather than the entire page. I already have the header and footer and scripts. I only need center content. Similar to a burger, I just want the meat not the bun and tomato :) – Neil Sep 29 '14 at 16:04