为什么我在http://***/hr/lunch/init/2011/9 这个页面执行完某个操作之后,该页面的地址会变成http://***/hr/lunch/init/2011/9# 后面多出个#,导致下面代码中的 location = location.href不管用了$('.save').click(function(){
if(confirm('저장 하시겠습니까?'))
{
var days = [];
var year = $('input[name="year"]').val();
var month = $('input[name="month"]').val();
var worker = $('select[name=new_workers]').val();$.each($('#lunchCalander').find(':input[type=checkbox]:checked'), function(){
days.push(this.value);
});$.post('/hr/lunch/lunch_init', {'days':days,'year':year,'month':month,'worker':worker}, function(res){
if(res.error == true)
{
alert('error');
}
else
{
location = location.href;
}},'json');
}
});

解决方案 »

  1.   

    还有个问题,当在别的页面中跳转到该页面(http://***/hr/lunch/init/2011/9)的时候,怎么把url上的日期给隐藏掉。
    http://***/hr/lunch/init/2011/9  是跳转到这个地址上,但怎么把/2011/9 这部分进行隐藏,不让用户看到
      

  2.   

    空白链接自动添加的?  那怎么才能不让添加这个啊? 因为我要执行location = location.href; 这个操作,因为多了个#,所以不能刷新本页面
      

  3.   

    4楼的试过了, 貌似还不行 $('.save').click(function(){
    if(confirm('저장 하시겠습니까?'))
    {
    var days   = [];
    var year   = $('input[name="year"]').val();
    var month  = $('input[name="month"]').val();
    var worker  = $('select[name=new_workers]').val();

    $.each($('#lunchCalander').find(':input[type=checkbox]:checked'), function(){
        days.push(this.value);
    });

    $.post('/hr/lunch/lunch_init', {'days':days,'year':year,'month':month,'worker':worker}, function(res){
    if(res.error == true)
    {
    alert('error');
    }
    else
    {
    //location = location.href;
    document.location=document.location.href;
    }

    },'json');
    }
    });
      

  4.   

    楼主,这样做吧。
    如果自己页面上含有空连接的话这样写:
        <a href="javascript:void(0)"></a>
        <%--而不是--%>
        <a href="#"></a>
      

  5.   

    把location = location.href; 换成 window.location.reload(); 一切就ok了,页面重新加载就ok了。