I have been searching for an answer to this but have not been able to
find one suitable for the situation.
What I am trying to accomplish is to use an onClick event to load html
data via jQuery's .ajax() function within a specified div.
The requested html data contains a map element displaying their
computer location. I understand the limitations of the http protocol
as a stateless procedure does not execute the newly loaded html data
and its associated javascript functions (in this case the google maps
api), without being told to do so.
I am sure someone has come across this and I would would like to know
how it was over come.
Here is what I am working with
<script type="text/javascript" src="
http://maps.google.com/maps/api/js?
sensor=true"></script>
<script type="text/javascript">
var $j = jQuery.noConflict();
$j(document).ready(function(){
$j('#reg').click(function(){
$loadModules('register', 'register.html');
});
function $loadModules($key, $value){
$j.ajax({
url:'proxy.php',
type:'post',
data:'module='+$value,
context:$j('#'+$key),
dataType:'html',
success: function($response){
$j('#'+$key).html($response);
$initialize();
}
});
return false;
}
function $initialize(){
var myLatlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 8,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById('map'),
myOptions);
}
});
</script>