如何使用http post AngularJS将数据从php返回到页面?

My AngularJs page

  var postContactFn = function($http,data){
        return $http.post("myfirstfile.php", data);
    }

mainModule.factory('postContact',['$http',postContactFn]);

//In my controller

    postContactFn(data).success(function(data, status) {
        if(data){
                  console.log('success');
          }
    }

Php page MyFirstFile.php

 <?php
$name = $_POST['inputUsername']; 
if(!empty($name)){
  --send mail
 echo 'success'
}

Here the mail is been sent to my id but I'm not getting redirected back the controller. Instead it is showing success on my page.

Any suggestions would be appreciated.. Thank you

查看全部
dtsps2098
dtsps2098
2016/02/09 01:43
  • php
  • angularjs
  • ajax
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复