【问题标题】:Is there a way to refresh the page with jquery without doing a location.reload()?有没有办法在不执行 location.reload() 的情况下使用 jquery 刷新页面?
【发布时间】:2014-05-23 05:51:17
【问题描述】:

我有一个脚本可以检查两个或多个选项是否相同。如果它们相似,我会阻止该页面被提交。它有效,但前提是我在显示警报消息后刷新页面。如果我选择了一个有利的选项,错误警报仍在内存中,除非我刷新页面。

我想我可以执行“location.reload()”,但用户等待页面重新加载。有什么我可以在不执行 location.reload() 的情况下刷新页面的吗?这是我的脚本:

$("#saveBtn").click(function () {

    for (var x = 0; x < checkedindex.length; x++) {
        var ind = checkedindex[x];

        var dateofclass = $(".TextBoxDate:eq(" + ind + ")");
        var timeofclass = $(".TextBoxTime:eq(" + ind + ")");
        var classday = $("select[name='searchString']:eq(" + ind + ")");

        classdate.push(dateofclass);
        classtime.push(timeofclass);
        dayofclass.push(classday);

        var testString = (dayofclass[x].val() + classtime[x].val()).toString();


        if (testString.indexOf(oldDateAndTime) == 0)//returns -1 if no match is found 0 means a match was found…. there are two or more of the same string
        {
             alert("Please make the correct selection");
             return false;
        }
        oldDateAndTime = (dayofclass[x].val() + classtime[x].val()).toString();
     }
 });

【问题讨论】:

  • @RohitBatham,阅读问题标签...

标签: jquery asp.net-mvc


【解决方案1】:

以下是使用 javascript 重新加载页面的 535 种方法

http://www.phpied.com/files/location-location/location-location.html

【讨论】:

    【解决方案2】:
     history.go(0);
    

    使用历史方法

    【讨论】:

      猜你喜欢
      • 2020-08-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-29
      • 2010-09-26
      • 2019-07-24
      • 1970-01-01
      相关资源
      最近更新 更多