-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
57 lines (49 loc) · 1.49 KB
/
script.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
//dev mode
//var uri = "https://small-scale-lending-api-btvanhooser.c9users.io:8080";
//prod mode
var uri = "https://simple-lending-api.herokuapp.com/";
sessionStorage.setItem('uri', uri);
var settingsForTempUsers = {
"async": true,
"crossDomain": true,
"url": uri + "/CreateTempWebUser",
"method": "GET"
}
var settingsForAuth = {
"async": true,
"crossDomain": true,
"url": uri + "/auth",
"method": "POST",
"headers": {
"content-type": "application/json"
},
"processData": false
}
var settingsForLenders = {
"async": true,
"crossDomain": true,
"url": uri + "/lenders",
"method": "GET"
}
$.ajax(settingsForTempUsers).done(function (response) {
settingsForAuth.data = JSON.stringify(response);
$.ajax(settingsForAuth).done(function (response) {
sessionStorage.setItem('access_token', response.access_token);
settingsForLenders.headers = {"Authorization":"JWT " + response.access_token};
$.ajax(settingsForLenders).done(function (response) {
$.each(response.Lenders, function(iteration,lender){
if (lender.lendercode != "000") {
var o = new Option(lender.name, lender.lendercode);
$(o).html(lender.name);
$("#lenderDropDown").append(o);
}
});
});
});
});
function onSubmit(){
var element = jQuery('#lenderDropDown option:selected');
sessionStorage.setItem('lendercode',element.val());
sessionStorage.setItem('lendername',element.text());
location.href = 'submit.html';
}