Я добавил панель поиска на картах, и она работала нормально, но когда я начал сеанс, что-то случилось, и вдруг он перестает работать. Когда я удаляю сеанс, он работает, но с сеансами он не работает. Кто-нибудь?строка поиска не работает после 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
это html-код: -
–
Чувак, код PHP вызывает ERROR, и дал нам HTML :) –