Take the 2-minute tour ×

I am trying to load one html page into another html page using this javascript

$('.myajax').click(function() {
    var myhref=$(this).attr('href');
    return false;

The problem arises whenever I try to load a Google Map into that div, named contentdiv. Whenever I try to do so, nothing appears on the browser; it goes complete blank. The page containing the Google map goes as follows :

<!DOCTYPE html>
   <title>Google Maps Geocoding Demo</title> 
   <script type="text/javascript"> 
   var address = 'London,UK';
       mapTypeId: google.maps.MapTypeId.ROADMAP,
       zoom: 6

   var geocoder = new google.maps.Geocoder();
      'address': address
   function(results, status) {
      if(status == google.maps.GeocoderStatus.OK) {
         new google.maps.Marker({
            position: results[0].geometry.location,
            map: map
      else {
         // Google couldn't geocode this request. Handle appropriately.


Can someone point out the error ??

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

When you use $.load() it loads all the data outputed, so you are loading nothing in your <head>, you are not loading the google maps api, nor the javascript, at least not in a way it could be processed I think, never tried that but it's definetively not the use $.load() was intended for.

You would have to use iframes or try to actually include the google maps library and run the javascript code in the actual page when it comes to that page including google maps.

share|improve this answer
When I try to put the javascript and include the css in the original page itself, then the div loads properly, but not the map !! –  OneMoreError Nov 26 '12 at 13:44
Of course, you are trying to load the map into #map (´var map = new google.maps.Map(document.getElementById('map'), { ´) while it's not loaded yet. You can't load the map that way or it's not very clean at least. What you could do is an If statement (if myref == "googlemapsPage") execute the script that loads the map instead of loading a page –  aleation Nov 26 '12 at 13:48
I am facing similar problem, could you please tell me how you made it to work. –  Raj Dec 13 '12 at 2:14
add comment

Your Answer


