在GetJson更改URL历史记录

时间:2012-11-21 13:49:22

标签: javascript jquery json

如果我的地址是“http:// localhost:8000 / index”,我运行这个jquery:

 $.getJSON("1",function(data)
        {       
            .....code
        });

我得到“http:// localhost:8000 / index / 1”。那很棒。但如果我这样做,如果我想要它: “HTTP://本地主机:1分之8000” 我该怎么办?

1 个答案:

答案 0 :(得分:3)

使url root-relative:

$.getJSON("/1", function(data)
{
     .... code
});

具体来说,请注意网址开头的/。这就是将它指向当前站点的根目录,在这种情况下:http://localhost:8000/

相关问题