【发布时间】:2016-06-24 14:48:59
【问题描述】:
为什么我的根路径在这个函数中被加倍了?
function bodyClass(id) {
var catName = $('#location').children().eq(4).text(),
rootPar = ("http://localhost/site/" + catName),
banner = $('#wantedDiv'),
// this load variable doubles up the root path and does not escape the first single quote
content = $('<div />').load("'" + rootPar + " " + banner + "'", function(){
$('#placeDiv').prepend(content.html());
});
// console logging retrieves the correct path inclusing the added "catName"
console.log(rootPar);
}
bodyClass();
这是浏览器控制台向我显示的内容:
console.log:http://localhost/site/page
load() 函数: GET http://localhost/site/'http://localhost/site/page' 404(未找到)
【问题讨论】: