讀取XML我有一個商店定位器,使用谷歌地圖,PHP/MySQL和jQuery的建在這裏。 IE7,8無法讀取動態通過parse_location.php
IE8,並通過AJAX
Ajax代碼生成的XML:
function reloadMap(map, dataString) {
markersArray = [];
var infoWindow = new google.maps.InfoWindow({content: "loading...", maxWidth:100});
var storeListHtml = '<h2>Name <span style="margin-left:252px;">Address</span></h2><ul>';
$.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 = "<span class='info'><b>" + name + "</b> <br/>" + address + "</span>";
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 += "<li class='store'><a href='javascript:myclick("+count+")'><div class='store-name'>"+name+"</div><div class='store-add'> "+address+"</div></a></li>";
bindInfoWindow(marker, map, infoWindow, html);
});
storeListHtml += '</ul>';
$("#store-list").html(storeListHtml);
}
});
}
正如你所看到的,這涉及調用parse_location.php,讓生成的XML通過以下代碼: //取消註釋以下行會導致ff,safari等人不顯示任何內容。 // header('Content-Type:text/xml; charset = UTF-8');
$responce = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$responce .= "<location>\n";
$city = $_GET['city'];
$category = $_GET['category'];
[SQL查詢這裏]
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result))
{
$responce .= "<list name=\"".$row["name"]."\"
address=\"".$row["street_address"]." ".$row["city"]." ".$row["state"].", ".$row["zip"]."\"
lat=\"".$row["lat"]."\"
lng=\"".$row["lng"]."\" />";
}
$responce .= "</location>";
$responce8 = utf8_encode($responce);
echo $responce8;
任何指針???
仙人
您應該在代碼片段之前和之後添加一個空行,以確保它們的格式正確。除此之外:您是否嘗試過直接通過IE地址欄打開腳本的URL?這將有助於瞭解問題是關於內容還是xhr請求本身。 – 2011-04-01 18:08:09
嘿herenvardo,謝謝你的提示,我一定會更好地格式化代碼,這是我第一次在問題中發佈代碼。 這就是說,我試着直接運行parse_location.php,並且只是在該頁面上輸出用戶代理。真的不知道該怎麼做。 – frishi 2011-04-01 19:44:29