我经常看到一些代码中,所联系的ajax文件(下面示例中的somefile.php)前面都有一个/
这个/仅仅是为了保留www.example.com/somefile.php的结构,还是出于安全的原因,比如转义?如果是后者,一个解释也会有帮助..
$.post('/somefile.php', { id: id, val: val }, function(data) {
if (something) {
do something
} else {
do something else
}
});谢谢。
发布于 2009-10-18 02:05:07
它指向网站的根目录,就像链接或图片中的其他url一样。
例如,如果您使用的是http://example.com/sub/site.html,则somefile.php会转到http://example.com/sub/somefile.php,而/somefile.php会转到http://example.com/somefile.php
https://stackoverflow.com/questions/1582825
复制相似问题