-
Notifications
You must be signed in to change notification settings - Fork 0
/
Test_DataEntry.js
83 lines (64 loc) · 2.05 KB
/
Test_DataEntry.js
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
define( [
'./properties',
'./initialproperties',
'text!./template.html'
],
function ( props, initProps, ngTemplate ) {
'use strict';
return {
definition: props,
initialProperties: initProps,
snapshot: {canTakeSnapshot: false},
template: ngTemplate,
controller: ['$scope', function ( $scope ) {
$scope.myTitle = 'This is my AngularJS table';
$scope.submit = function () {
alert('dentro SUBMIT!!!');
alert(window.location);
var str = {};
var fld = 'firstName';
var ffn = $scope.user.firstName;
str[fld] = ffn;
fld = 'lastName';
var fln = $scope.user.lastName;
str[fld] = fln;
var jsonTxt = JSON.stringify(str, null, '\t');
//var result = $.param(jsonTxt);
//jsonTxt = 'firstName=' + ffn + '&lastName=' + fln;
console.log(jsonTxt);
//console.log(result);
jQuery.support.cors = true;
//$.post('http://localhost:3000/endpoint', jsonTxt);
// ******* se metto $.post l'url diventa http://localhost:4848/sense/[object%20Object] *******
$.ajax({
url: "http://localhost:3000/endpoint" + '/jsonp?callback=?',
type: 'GET',
data: jsonTxt,
crossDomain: "true",
//processData: "false",
contentType: "application/json; charset=utf-8",
dataType: "jsonp",
jsonpCallback: 'callback',
cache: false,
async: false,
jsonp: 'jsonp',
// Work with the response
success: function( resp ) {
console.log('success');
console.log( resp ); // server response
console.log(resp.firstName);
console.log(resp.lastName);
},
error: function (request, status, error) {
alert(request.responseText);
//console.log('Uh Oh!');
}
/*error: function() {
console.log('Uh Oh!');
}*/
});
};
}]
};
}
);