javascript - 如何使用angularJS在成功提交后刷新页面

标签 javascript jquery python angularjs django

嗨,如何在成功提交后刷新 html 页面? 我试过如下,但它不工作。

$scope.submit =function(){
        data = {};
        angular.extend(data, $scope.final_data);
        angular.extend(data, { checks : $scope.final_data.checks });
        $http.post('{% url 'submit' %}', data).success(
            function(data){
                alert('succesfully submitted');
                $location.path('{% url 'orc_checkbinning' %}');
            }).error(function(){
                alert('not submitted');
        })
    };

我正在为我的项目使用 Django 框架。任何想法?提前致谢。

最佳答案

Definition and Usage The reload() method is used to reload the current document. The reload() method does the same as the reload button in your browser. By default, the reload() method reloads the page from the cache, but you can force it to reload the page from the server by setting the forceGet parameter to true: location.reload(true).

Use this updated code.

$scope.submit =function(){
        data = {};
        angular.extend(data, $scope.final_data);
        angular.extend(data, { checks : $scope.final_data.checks });
        $http.post('{% url 'submit' %}', data).success(
            function(data){
                alert('succesfully submitted');
                   $scope.reloadPage = function()                                                
                   {
                     $window.location.reload();
                   }
                }).error(function(){
                    alert('not submitted');
            })
        };

关于javascript - 如何使用angularJS在成功提交后刷新页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33028720/

相关文章:

javascript - 如何获取所有选中的复选框

javascript - 您将如何使用正则表达式验证一串手机号码?

javascript - JQuery 用户界面 : multiple progress bar - problems to set dynamic values

javascript - 隐藏/显示某些 UL 元素?

javascript - 如何使用 jquery 禁用页面上的所有链接和输入按钮

javascript - 如何测量javascript中的字体指标?是否有任何 API 可用于 C# 中的 GetCellDescent 等文本指标?

python - 如何在 Google Colab 中运行 FastAPI/Uvicorn?

python - 阵列 : slice coordinates with no dimensions

python - 合并返回奇数长度

javascript - 如何在可视化上添加点 : Area Chart