Javascript 会话启动后搜索栏不工作()
我在“地图”中添加了一个搜索栏,它工作正常,但当我开始会话时,发生了一些事情,它突然停止工作。当我删除会话时,它可以工作,但在会话中它不工作。 有人吗 我的PhP代码Javascript 会话启动后搜索栏不工作(),javascript,php,jquery,html,session,Javascript,Php,Jquery,Html,Session,我在“地图”中添加了一个搜索栏,它工作正常,但当我开始会话时,发生了一些事情,它突然停止工作。当我删除会话时,它可以工作,但在会话中它不工作。 有人吗 我的PhP代码 <?php session_start(); if(isset($_SESSION['username']) && $_SESSION['username']!="") { ?> <input type="text" value="" id="searchbox">
<?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");
}
?>
我甚至没有看过你的代码,但我要冒险说,这很可能是因为你没有将
session\u start()
放在页面的最顶端。如果在调用session_start()
函数之前有任何
空格,PHP将抛出一个错误。查看html页面的源代码。看起来php生成了一个错误,以前发送了头…
,这使您的html代码无效。这是html代码:-杜德,php代码导致错误,你给了我们html:)在php中,我刚刚开始会话。比如:-session_start()@jQuery生气的Birdi说,不管你在这里粘贴什么初始PHP代码。而且您根本没有进行通信:PHP与JAVASCRIPT代码。好啊请粘贴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);
}
}
});
});