繁体   English   中英

将数据提交到数据库后重定向到新页面的最佳方法? 角/ PHP的/ MySQL的

[英]Best way to redirect to new page after submitting data to db? angular/php/mysql

使用PHP成功将angularjs表单提交到MySQL数据库后,我想将用户发送到其他页面。 最好的方法是什么?

php标头(位置:myurl)...。无法捕获数据,

回显-javascript window.location.replace(myurl)...插入数据,但不重定向。

假设您要通过AngularJS提交表单,最好从Angular端处理此重定向,而不是尝试使PHP重定向与AJAX请求一起使用。

成功完成POST请求后,可以在回调中使用Angular的$location服务:

app.controller('TestCtrl', function( $http, $location ){
  var req = {
    method: 'POST',
    url: 'http://example.com',
    data: { test: 'test' }
  };

  $http(req).then(function(){
    // this is executed after the request is completed successfully

    $location.path('/success-page');
  });
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM