尝试重定向时出错。它是在我安装了一个带有自动完成功能的搜索框后才开始的。当我取出代码时,页面会再次正确重定向。我知道这不是我的php.ini设置。
这是我得到的错误:
警告:无法修改标头信息-标头已由发送(输出开始于/home/content/67/621767/html/nav.php:9)/home/content/67/621767/html/admin/inclutes/functions2.php,第7行
这是导致问题的代码。谢谢你的帮助!
$(function() { $.ajax({
url: "/admin/includes/links.xml",
dataType: "xml",
success: function( xmlResponse ) {
var data = $( "link", xmlResponse ).map(function() {
return {
value: $( "title", this ).text(),
id: $( "url", this ).text()
};
}).get();
$( "#tags" ).autocomplete({source: function (request, response) {
var term = $.ui.autocomplete.escapeRegex(request.term)
, startsWithMatcher = new RegExp("^" + term, "i")
, startsWith = $.grep(data, function(value) {
return startsWithMatcher.test(value.label || value.value || value);
})
, containsMatcher = new RegExp(term, "i")
, contains = $.grep(data, function (value) {
return $.inArray(value, startsWith) < 0 &&
containsMatcher.test(value.label || value.value || value);
});
response(startsWith.concat(contains));
},
select: function( event, ui ) { window.location.href = ui.item.id; }
});
}
});
});
由于您没有发布导致错误的PHP代码,这是我能提供的最好的创可贴解决方案。
在函数2.php中,将ob_start();
放在顶部。这里有一些资源可以解释这一点:
http://brian.moonspot.net/php-ob-start-headers
http://php.net/ob_start
问题不在于javascript,而在于php输出。在您编写标题和发送信息之前,php脚本中有一些内容正在尝试编写(可能是php错误)。php脚本的第7行和第9行是什么?