簡體   English   中英

角形式不通過郵寄提交

[英]Angular form not submitting via post

請檢查為什么該角度代碼不通過郵寄提交網址。 我正在嘗試通過短信發送表單詳細信息,以通過手機發布請求。

<div id="page7-container1" ng-app="amApp">
      <h4 id="page7-heading1" style="color:#000000;">App</h4>
      <div id="page7-markdown3" class="show-list-numbers-and-dots">
      </div>
      <div id="page7-markdown6" class="show-list-numbers-and-dots">
      </div>
      <div id="page7-markdown5" class="show-list-numbers-and-dots">
      </div>
      <div id="page7-markdown4" class="show-list-numbers-and-dots">
      </div>
      <h3 id="page7-heading4" style="color:#337AE2;font-weight:600;">Request a call back</h3>
      <form id="page7-form2" class="list" ng-controller="formCtrl" ng-submit="submitForm()">
        <label class="item item-input item-floating-label" id="page7-input0">
          <input type="text" name="formAdata.rname" required placeholder="Enter Your Name">
        </label>
        <label class="item item-input item-floating-label" id="page7-input1">
          <input type="number" name="formAdata.rmobile" required placeholder="Enter Mobile Number">
        </label>
        <label class="item item-input item-floating-label" id="page7-input2">
          <input type="text" name="formAdata.rlocation" required placeholder="Enter Your location/district/state?">
        </label>
        <input id="page7-button12" type="submit" ngClick="Submit" class="button button-positive  button-block" value="Request call back!">
      </form>
        <script language="javascript">
            var messager = '';
            var app = angular.module('amApp', []);
            app.controller('formCtrl', function ($scope, $http) {
                $scope.submitForm = function() {
                    messager = "http://amritamultimedia.co.in/sms/sendsms.php?uid=9947009540&pwd=A3228B&msg=I am "+$scope.formAdata.rName+" from "+$scope.formAdata.rLocation+". My mobile number is: "+$scope.formAdata.rMobile+", I would like to get more info about Courses. Requested call back from your Mobile App, Please call me to my mobile.";
                    $http({
                        url: messager,
                        method: "POST",
                        headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                        data: $.param($scope.formAdata)
                    }).success(function(data, status, headers, config) {
                        document.getElementById("page7-form2").innerHTML = "We will get back to you within 3-4 hours. Thanks for checking our app.";
                    }).error(function(data, status, headers, config) {

                    });
                };
            });
        </script>
    </div>

必須缺少什么,或者做錯了什么?

請幫忙!

謝謝j

將此添加到您的控制器

$scope.formAdata={};

您使用json參數,因此您的formAdata無法正確綁定。

還要檢查您使用的是POST,但像查詢字符串那樣傳遞數據,因此需要綁定並作為json對象發送或使用GET方法。

再檢查一遍,因為沒有提到數據類型,所以再次檢查是否已分配Messenger的值

var app = angular.module('amApp', []);
app.controller('formCtrl', function ($scope, $http) {
    $scope.formAdata={};
    var messager = "";
    $scope.submitForm = function() {
        messager = "http://amritamultimedia.co.in/sms/sendsms.php;
        var userData={
        "uid":mobilenumber,
        "pwd":password,
        "phone":$scope.formAdata.phone,
        "msg": $scope.formAdata.message
        }
        $http({
            url: messager,
            method: "POST",
            headers: {'Content-Type': 'application/x-www-form-urlencoded'},
            data: userData,
        }).success(function(data, status, headers, config) {
            document.getElementById("page7-form2").innerHTML = "We will get back to you within 3-4 hours. Thanks for checking our app.";
        }).error(function(data, status, headers, config) {

        });
    };
});

這將起作用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM