-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
64 lines (54 loc) · 1.76 KB
/
index.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
/**
* Created by hodrigohamalho@gmail.com on 24/07/14.
*/
$( document ).ready(function() {
$("#button-java").click(function(e){
e.preventDefault();
var url = $(this).parent().attr("href");
$.ajax({
url: url,
type: "GET"
}).done(function(result) {
$("#another-sp-content").html(result);
})
});
$("#button-ajax").click(function(){
// SEND GET Request to SP
$.ajax({
url: "/sales-post/",
type: "GET"
}).done(function(result) {
if (result.indexOf("SAMLRequest") == -1){
$("#another-sp-content").html(result);
return;
}
var form = $(result)[1];
var action = $(form).attr("action");
var samlRequestName = $(form).find("input").attr("name");
var samlRequestValue = $(form).find("input").attr("value");
var samlJson = {};
samlJson[samlRequestName] = samlRequestValue;
// SEND POST request to IDP with SAMLRequest param
$.ajax({
url: action,
type: "POST",
data: samlJson
}).done(function(result) {
var form = $(result)[1];
var action = $(form).attr("action");
var samlResponseName = $(form).find("input").attr("name");
var samlResponseValue = $(form).find("input").attr("value");
var jsonData = {};
jsonData[samlResponseName] = samlResponseValue;
// SEND POST request to sales-post with SAMLResponse param
$.ajax({
url: action,
type: "POST",
data: jsonData
}).done(function(result) {
$("#another-sp-content").html(result);
});
});
});
});
});