我经常看到代码,其中联系的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
}
});
Run Code Online (Sandbox Code Playgroud)
谢谢.
它指向网站的根,就像链接或图像中的每个其他网址一样.
例如,如果你在http://example.com/sub/site.html,somefile.php去http://example.com/sub/somefile.php,而 /somefile.php进入http://example.com/somefile.php
| 归档时间: |
|
| 查看次数: |
242 次 |
| 最近记录: |