现有多个页面(test1.html、test2.html、index.html)需要包含某个页面(header.html),且这多个页面位于不同的目录,如下所示
Item/
js/
main.js
images/
...
about/
test1.html
...
contact/
test2.html
...
index.html
header.html
通过ajax来实现页面包含时,请求的url改如何填写?
//main.js
...
xmlHttp.open("GET",url,true);
xmlHttp.send();
...
而且被包含的页面header.html有图片资源,这个图片资源的链接又该如何写?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
假设页面 a 访问路径
//domain.com/a,图片 i 访问路径//domain.com/assets/img。那么其他各种不同路径的资源,例如
//domain.com/b、//domain.com/c/d等等,访问 a 的话路径写/a即可,a 中使用图片 i 路径写/assets/img即可。题主是这个意思么?
比如 “http://www.baidu.com?time”+参数名
按各自的位置来写,header.html就以它的位置写图片的路径
如果参数较多,建议将其封为array/object