不通过帖子提交的角度形式
请检查此角码不通过帖子提交网址的原因。我试图通过短信发送我的表单详细信息,通过手机发布请求。不通过帖子提交的角度形式
<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>
什么必须丢失,或者做错了什么?
请帮忙!
感谢, Sj的
添加到您的控制器
$scope.formAdata={};
您使用JSON参数,使您的formAdata不会才能正确绑定。
另外,请检查您使用POST但通过像查询字符串数据,因此需要bindand发送作为JSON对象或使用GET方法。
还有一件事要仔细检查信使的价值越来越被分配与否,因为没有数据类型提到
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) {
});
};
});
这将工作。
让我检查...会回复你..谢谢Aravind – yjs
你的代码似乎没问题,但在正确的场景下不起作用。现在让我解释一下试图获得什么...我使用github插件来连接way2sms来发送短信以获取客户端请求到移动设备。它在浏览器网址中给出并提交时正常工作。但是,在提交表单时,是否可以通过角度后置方法来做到这一点?希望你得到了真正的问题.... 以下网址工作正常时提交浏览器的网址,这是试图从角度提交使用... http://amritamultimedia.co.in/sms/sendsms。 php?uid = 9947009540&pwd = A3228B&phone = 9947009540&msg = Hello + World – yjs
对不起fb ...目前来自工作场所。 – yjs
使用'ngClick =“submitForm()”'而不是'ngClick =“提交()”'在提交按钮 –