Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 向db提交数据后重定向到新页面的最佳方式?angular/php/mysql_Javascript_Php_Mysql_Angularjs - Fatal编程技术网

Javascript 向db提交数据后重定向到新页面的最佳方式?angular/php/mysql

Javascript 向db提交数据后重定向到新页面的最佳方式?angular/php/mysql,javascript,php,mysql,angularjs,Javascript,Php,Mysql,Angularjs,在使用php成功地将angularjs表单提交到MySQL数据库之后,我想将用户发送到另一个页面。最好的方法是什么 php标题位置:myurl。。。。不捕获数据- echoing-javascript window.location.replacemyurl。。。插入数据,但不重定向。假设您是通过AngularJS提交表单,最好从角度处理此重定向,而不是尝试让PHP重定向与AJAX请求一起工作 在POST请求成功完成后,您可以在回调中使用Angular的$location服务: app.cont

在使用php成功地将angularjs表单提交到MySQL数据库之后,我想将用户发送到另一个页面。最好的方法是什么

php标题位置:myurl。。。。不捕获数据-


echoing-javascript window.location.replacemyurl。。。插入数据,但不重定向。

假设您是通过AngularJS提交表单,最好从角度处理此重定向,而不是尝试让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');
  });
});

在Angular中,您必须在$http请求的回调中设置重定向。您需要完全重写该脚本。试图修复一点点将占用永久的头位置:myurl。。。。不捕捉数据你是什么意思?当PHP发送位置头时,PHP已经接受表单输入。你指的是什么?你在使用ajax吗?你捕获数据是什么意思?