Note that there are some explanatory texts on larger screens.

plurals
  1. POIE8 and reading XML via AJAX
    text
    copied!<p>I have a store locator, built using Google Maps, PHP/Mysql and jQuery here: <a href="http://tinyurl.com/4w8nwwp" rel="nofollow">http://tinyurl.com/4w8nwwp</a></p> <p>Everything is dandy in FF, Safari,Chrome and Opera. IE7, 8 cannot read the XML that is dynamically generated by <code>parse_location.php</code></p> <p>The AJAX code:</p> <pre><code>function reloadMap(map, dataString) { markersArray = []; var infoWindow = new google.maps.InfoWindow({content: "loading...", maxWidth:100}); var storeListHtml = '&lt;h2&gt;Name &lt;span style="margin-left:252px;"&gt;Address&lt;/span&gt;&lt;/h2&gt;&lt;ul&gt;'; $.ajax({ type: "GET", url: "parse_location.php", data: dataString, success: function(text){ count = -1; $(text).find("list").each(function() { count++; if(count == 0) { var burnsvilleMN = new google.maps.LatLng($(this).attr("lat"),$(this).attr("lng")); map.panTo(burnsvilleMN); } var store = [$(this).attr("name"), $(this).attr("address"), $(this).attr("lat"), $(this).attr("lng"), count]; var name = $(this).attr("name"); var address = $(this).attr("address"); var point = new google.maps.LatLng($(this).attr("lat"),$(this).attr("lng")); var html = "&lt;span class='info'&gt;&lt;b&gt;" + name + "&lt;/b&gt; &lt;br/&gt;" + address + "&lt;/span&gt;"; var image = new google.maps.MarkerImage('images/icon_dot2.png'); var shadow = new google.maps.MarkerImage('images/icon_dot_shadow.png'); var marker = new google.maps.Marker({ map: map, position: point, icon: image, shadow:shadow //shadow: icon.shadow }); //markersArray.push(marker); storeListHtml += "&lt;li class='store'&gt;&lt;a href='javascript:myclick("+count+")'&gt;&lt;div class='store-name'&gt;"+name+"&lt;/div&gt;&lt;div class='store-add'&gt; "+address+"&lt;/div&gt;&lt;/a&gt;&lt;/li&gt;"; bindInfoWindow(marker, map, infoWindow, html); }); storeListHtml += '&lt;/ul&gt;'; $("#store-list").html(storeListHtml); } }); </code></pre> <p>}</p> <p>As you can see, this involves calling parse_location.php, getting the XML generated by this code: // uncommenting the following line causes ff, safari et al to not show anything. // header('Content-Type: text/xml; charset=UTF-8');</p> <pre><code>$responce = "&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n"; $responce .= "&lt;location&gt;\n"; $city = $_GET['city']; $category = $_GET['category']; </code></pre> <p>[SQL Query here ] </p> <pre><code>$result = mysql_query($sql); while ($row = mysql_fetch_array($result)) { $responce .= "&lt;list name=\"".$row["name"]."\" address=\"".$row["street_address"]." ".$row["city"]." ".$row["state"].", ".$row["zip"]."\" lat=\"".$row["lat"]."\" lng=\"".$row["lng"]."\" /&gt;"; } $responce .= "&lt;/location&gt;"; $responce8 = utf8_encode($responce); echo $responce8; </code></pre> <p>Any pointers???</p> <p>Rishi</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload