javascript - Google Api Asynch Callback Failed -


i getting requested content with:

function httpget(theurl) {     var xmlhttp = new xmlhttprequest();     xmlhttp.open( "get", theurl, false );     xmlhttp.send( null );     alert(xmlhttp.status);     return xmlhttp.responsetext; } 

after content parsed new site via:

$test = httpget("www.content.com"); document.getelementbyid("div_content").innerhtml = document.getelementbyid("div_content").innerhtml + $test; 

after use google api asynch callback callback function thorws error

loadscriptfunc('https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true&callback=loadscript'); 

the error is: window.loadscript not function

i did jquery $.get , worked me.

edit: function loaded this:

if(document.getelementbyid('map_canvas')){             loadscriptfunc('https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true&callback=loadscript');           }  

the function looks like:

function loadscriptfunc(url)  {    var head = document.getelementsbytagname('head')[0];    var script = document.createelement('script');    script.type = 'text/javascript';    script.src = url;    head.appendchild(script); }    

and loadscript functions looks that:

function loadscript() {            var head = document.getelementsbytagname('head')[0];            var script = document.createelement('script');            script.type = 'text/javascript';            script.src = 'http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/src/infobox.js';            head.appendchild(script);            bloaded = true;            window.settimeout("activatemap()", 100);          }   

the loadscript functions belongs template file of map. code worked me jquerys- $.get function same callback , on. not allowed use jquery...

edit2: found on internet , think know whats problem.

i have had success jquery.load() since executes javascript code blocks , resources present inside fetched content. sorry, no demo this!

i guess cant execute code xmlhttprequest, knows js method content url ??

ah, know happened. it's google maps tells can't find loadscript().

so, tell google maps: maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true&callback=loadscript

look happens; tell google maps call initialize instead.

<style>   #map_canvas {width: 400px; height: 400px;} </style> <div id="map_canvas"></div> <script> function initialize() {   var my_position = new google.maps.latlng(50.5, 4.5);   var map = new google.maps.map(document.getelementbyid('map_canvas'), {     center: my_position,     zoom: 7   }); } function loadscriptfunc(url) {   var head = document.getelementsbytagname('head')[0];   var script = document.createelement('script');   script.type = 'text/javascript';   script.src = url;   head.appendchild(script); } if(document.getelementbyid('map_canvas')) {   loadscriptfunc('https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true&callback=initialize'); } </script> 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -