dongzaheng4449 2015-07-02 04:43
浏览 56
已采纳

表单值不传递angularjs

Here is my app.js, I want to send the value of email to the file handler.php

$scope.doForget={email:''};
$scope.doForget = function (customer) {
     //email = $scope.forget.email; For Testing i am hardcoding the value
     email = 'abc@xyz.com';
     Data.post('handler.php', {
            email: email
        }).then(function (results) {
        console.log(results); 
        }); 
    };

In the Inspect Element -> Networks i can see the form values as {email: "abc@xyz.com"}

In the handler.php i use to print the values by print_r($_POST); and even print_r($_GET); but i am always getting the empty array i.e.,

Array
(
)

How can i get the values ?

Update :

I even tried this one

$scope.doForget={email:''};
$scope.doForget = function (email) {
 email = 'abc@xyz.com';
 Data.post('eloquent.php', {
        email: email
    }).then(function (results) {
    console.log(results);
    });
};
  • 写回答

1条回答 默认 最新

  • doudui5753 2015-07-02 05:31
    关注

    Just use in angular's controller :

    var emailNew = "demo@demo.com";
      $http({
         method : 'POST',
         url : 'relative_path_to_demo.php',
         data : {"email" : emailNew}
      })
    

    and in your server PHP file. Put code

    $data = file_get_contents("php://input");
    $objData = json_decode($data);
    
    $email = $objData -> email; // Get your email
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 CST仿真别人的模型结果仿真结果S参数完全不对
  • ¥15 误删注册表文件致win10无法开启
  • ¥15 请问在阿里云服务器中怎么利用数据库制作网站
  • ¥60 ESP32怎么烧录自启动程序
  • ¥50 html2canvas超出滚动条不显示
  • ¥15 java业务性能问题求解(sql,业务设计相关)
  • ¥15 52810 尾椎c三个a 写蓝牙地址
  • ¥15 elmos524.33 eeprom的读写问题
  • ¥15 用ADS设计一款的射频功率放大器
  • ¥15 怎么求交点连线的理论解?