-5
我在地圖上添加了一個搜索欄,它工作正常,但是當我開始會話時,發生了一些事情,突然它停止工作。當我刪除會話,它的工作原理,但會議它不起作用。 有人嗎?搜索欄不工作後session_start()
我的PHP代碼
<?php session_start();
if(isset($_SESSION['username']) && $_SESSION['username']!="")
{
?>
<input type="text" value="" id="searchbox">
<?php
}
else
{
//echo "You are not supposed to be here. Please <a href='login.php'>login</a> first.";
header("Location:login.php");
}
?>
代碼:
$(function() {
$("#searchbox").autocomplete({
source: function(request, response) {
if (geocoder == null) {
geocoder = new google.maps.Geocoder();
}
geocoder.geocode({
'address': request.term
}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var searchLoc = results[0].geometry.location;
var lat = results[0].geometry.location.lat();
var lng = results[0].geometry.location.lng();
var latlng = new google.maps.LatLng(lat, lng);
var bounds = results[0].geometry.bounds;
geocoder.geocode({
'latLng': latlng
}, function(results1, status1) {
if (status1 == google.maps.GeocoderStatus.OK) {
if (results1[1]) {
response($.map(results1, function(loc) {
return {
label: loc.formatted_address,
value: loc.formatted_address,
bounds: loc.geometry.bounds
}
}));
}
}
});
}
});
},
select: function(event, ui) {
var pos = ui.item.position;
var lct = ui.item.locType;
var bounds = ui.item.bounds;
if (bounds) {
map.fitBounds(bounds);
}
}
});
});
看看html頁面的來源。它看起來像PHP生成一個錯誤'頭被以前發送......'這使您的HTML代碼無效。 – Cheery 2014-10-08 04:56:53
這是html代碼: -
– 2014-10-08 05:06:45
夥計,PHP代碼導致錯誤,你給我們HTML :) – 2014-10-08 05:07:46