gpt4 book ai didi

php - HTML 未在 Firefox 上显示

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:50:54 26 4
gpt4 key购买 nike

我试图通过 AJAX 返回一个 PHP 页面,它总是在 Chrome 中加载。在 Firefox 中,它大约有 5% 的时间加载,其他时间它什么也没有加载,没有 JS/PHP 错误。我只是在没有 CSS 的情况下直接回显 html。

这是我的 Ajax:

if(geo_position_js.init()){
geo_position_js.getCurrentPosition(displayPosition,error_callback,{enableHighAccuracy:true,options:5000});
}
else{
alert("Functionality not available");
}

function error_callback(p)
{
alert('error='+p.message);
}

function displayPosition(loc) {
var mylat = loc.coords.latitude;
var mylong = loc.coords.longitude;
$.ajax({
type: "POST",
url: "distancetest.php",
data: "long="+mylong+"&lat="+mylat,
success: function(html2){
$('#locationinfo').html(html2);
console.log(html);
}
});

}

我的 PHP 基本上做了几次:

$query = "SELECT * FROM tbl_geo WHERE cat_id=1";
$result = mysql_query ($query) or die(mysql_error());
echo "<h2>Restaurants</h2>";
while ($row = mysql_fetch_array($result)){
if($row['lat'] != ''){
$distance = distance($_POST['lat'], $_POST['long'], $row['lat'], $row['lng'], "k");
if($distance < 2000){
$attractions[] = array('name' => $row['name'], 'address' => $row['address'], 'distance' => $distance);
}
}
}
$attractions = array_sort($attractions,'distance');
$attractions = array_values($attractions);
for ($i = 0; $i <= 10; $i++) {
if(isset($attractions[$i]['distance'])){
echo 'You are '.$attractions[$i]['distance'].'km away from '.$attractions[$i]['name'].' at '.$attractions[$i]['address'].'<br/>';
}
}

在某些浏览器中有效,但在其他浏览器中不显示任何内容。有什么想法吗?

更新:事实证明这是 Firefox 中的地理定位问题。它无法获得位置,但不会返回到 error_callback 函数。现场示例在这里:http://adamzwakk.com/geolocate/

最佳答案

您确定您的浏览器支持您的操作吗?

试试这个: http://html5demos.com/geo

您也可以下载wireshark,查看您发送和服务器返回的信息。

将空白 php 页面(只是回显一个随机字符串)放在您要生成 php 的同一目录中并查看它是否正常工作也是一种很好的做法。在基于 Windows 的服务器上,PHP 可以设置为在特定目录中工作是一个常见问题,并且由于错误安装可能会在其他目录中失败。每个浏览器处理错误和警告消息的方式不同,所以如果它在 chrome 中工作,并不意味着它在其他所有地方都工作。您尝试过 Safari 和 Opera 吗?

关于php - HTML 未在 Firefox 上显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4973170/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com