-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetRequestanguar.txt
63 lines (52 loc) · 2.34 KB
/
setRequestanguar.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
d<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="js/packages/angular.min.js"></script>
<script src="js/packages/jquery-3.1.0.min.js"></script>
<script>
var myApp = angular.module("myApp1", []);
myApp.controller("HttpPostController", function ($scope, $http, $log) {
$scope.SendHttpPostData = function () {
var dataJson = $.param({
firstName: $scope.firstName,
lastName: $scope.lastName,
age: $scope.age
});
$http({
method: "POST",
url: "/WebService.asmx/PostDataResponse",
data: dataJson,
ContentType: "application/json;charset=utf-8",
dataType: "json",
success: function (data, status, headers, config) {
$scope.ServerResponse = data;
$log.info($scope.ServerResponse);
$log.info(data);
alert(data);
},
error: function (data, status, header, config) {
$scope.PostDataResponse = "Data: " + data +
"<hr />status: " + status +
"<hr />headers: " + header +
"<hr />config: " + config;
alert("erorr");
}
});
}
});
</script>
</head>
<body ng-app="myApp1" ng-controller="HttpPostController">
<div runat="server">
<form runat="server" ng-submit="SendHttpPostData()">
<p>First Name: <input type="text" name="firstName" ng-model="firstName" required /></p>
<p>Last Name: <input type="text" name="lastName" ng-model="lastName" required /></p>
<p>Age : <input type="number" name="age" ng-model="age" required /></p>
<button runat="server" ng-click="SendHttpPostData1()">Reset</button></div>
<hr />
{{ ServerResponse }}
</form>
</div>
</body>