javascript - Uncaught TypeError: Cannot read property 'documentElement' of null Googlemap -


i realise question asked before, however, have strange bug. trying output data googlemap pgsql. when write query parameters coming form, data not outputted. xml file being created , query works in phppgadmin. however, if same query hard-coded, data outputted. ask why happens here code.

 <script type="text/javascript">   //<![cdata[  var customicons = {   7634: {     icon: 'images/markers/1.png'   },   7644: {     icon: 'images/markers/7.png'   },   7632: {     icon: 'images/markers/8.png'   },   7633: {     icon: 'images/markers/9.png'   },   7639: {     icon: 'images/markers/10.png'   },   7646: {     icon: 'images/markers/11.png'   },   7657: {     icon: 'images/markers/12.png'   },   7649: {     icon: 'images/markers/3.png'   },   7636: {     icon: 'images/markers/4.png'   },   7648: {     icon: 'images/markers/5.png'   },   7640: {     icon: 'images/markers/6.png'   },   7650: {     icon: 'images/markers/2.png'   } };    function initmap() {     var map = new google.maps.map(document.getelementbyid("map"), {     center: new google.maps.latlng(39.295614,23.241548),     zoom: 7,      maptypeid: google.maps.maptypeid.roadmap,     maptypecontrol: false,      maptypecontroloptions: {     style: google.maps.maptypecontrolstyle.horizontal_bar     },      navigationcontrol: true,      navigationcontroloptions: {      style: google.maps.navigationcontrolstyle.small      }   });   var infowindow = new google.maps.infowindow();    // change depending on name of php file   downloadurl("temr_1.php", function(data) {     var xml = data.responsexml;     var markers = xml.documentelement.getelementsbytagname("marker");     (var = 0; < markers.length; i++) {       var veh = markers[i].getattribute("veh");       var speed = markers[i].getattribute("speed");       var cons = markers[i].getattribute("cons");       var co = markers[i].getattribute("co");       var point = new google.maps.latlng(           parsefloat(markers[i].getattribute("lat")),           parsefloat(markers[i].getattribute("lng")));       var html = "<b>" + veh + "</b> <br/>" + speed + "</b> <br/>" + cons + "</b> <br/>" + co;       var icon = customicons[veh] || {};       var marker = new google.maps.marker({         map: map,         position: point,         icon: icon.icon       });       bindinfowindow(marker, map, infowindow, html);     }   }); }  function bindinfowindow(marker, map, infowindow, html) {   google.maps.event.addlistener(marker, 'click', function() {     infowindow.setcontent(html);     infowindow.open(map, marker);   }); }  function downloadurl(url, callback) {   var request = window.activexobject ?       new activexobject('microsoft.xmlhttp') :       new xmlhttprequest;    request.onreadystatechange = function() {     if (request.readystate == 4) {       request.onreadystatechange = donothing;       callback(request, request.status);     }   };    request.open('get', url, true);   request.send(null); }  function donothing() {}  //]]> 

here php code query. variable $acase multiple selection box , array.

<?php  $datefrom= $_post[date_from]; $acase = $_post[vehid]; $date_to = $_post[date_to];  foreach ($acase $a){    $counter++; }  header("content-type: text/xml"); $dom = new domdocument("1.0"); $node = $dom->createelement("markers"); $parnode = $dom->appendchild($node);   // opens connection mysql server $con= pg_connect("host=localhost port=5432 dbname=temr user=postgres    password=evan");  if (!$con) {     print("connection failed.");     echo "failed";     exit; }    $query = pg_query($con, "select * gps_data vehicleid in    (".implode(',', $acase).")"); //$query = pg_query($con, "select * gps_data vehicleid in (7644,7632)"); -- works, same parameterised query    if (!$query) {   echo "oh no.\n";   exit; }  while ($row = pg_fetch_assoc($query)){     $node = $dom->createelement("marker");     $newnode = $parnode->appendchild($node);     $newnode->setattribute("veh",$row['vehicleid']);     $newnode->setattribute("speed", $row['speed']);     $newnode->setattribute("lat", $row['latitude']);     $newnode->setattribute("lng", $row['longitude']);     $newnode->setattribute("cons", $row['consumption']);     $newnode->setattribute("dis", $row['distance']);     $newnode->setattribute("co", $row['co2']);    }    echo $dom->savexml();   ?> 


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -