Skip to content

Instantly share code, notes, and snippets.

@mutukrish
Created June 15, 2015 10:37
Show Gist options
  • Save mutukrish/eb2a13bfc1cc5fb16d00 to your computer and use it in GitHub Desktop.
Save mutukrish/eb2a13bfc1cc5fb16d00 to your computer and use it in GitHub Desktop.
aegon cors
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Fix Cross Domain Ajax request CORS" />
<meta charset="utf-8">
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"></script>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" />
<link href='http://fonts.googleapis.com/css?family=Roboto:400,500' rel='stylesheet' type='text/css'>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css" rel="stylesheet">
<title>Fixing Cross Domain Ajax Request</title>
</head>
<body ng-app="myApp">
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<a class="navbar-brand" href="#">CORS Fix Demo</a>
</div>
</div><!-- /.container-fluid -->
</nav>
<div class="container">
<div ng-controller="MyCtrl">
<div class="row">
<div class="col-xs-12">
<div class="list-group">
<a href="#" class="list-group-item" ng-repeat="day in days">
<h4 class="list-group-item-heading">{{day.day_of_week}}</h4>
<p class="list-group-item-text">
{{day.condition}} <br />
</p>
</a>
</div>
</div>
</div>
</div>
</div>
<script id="jsbin-javascript">
var myApp=angular.module("myApp",[]);
myApp.config(['$httpProvider', function($httpProvider) {
$httpProvider.defaults.headers.common["X-Requested-With"] = 'XMLHttpRequest';
}]);
myApp.controller("MyCtrl",['$scope','$http','$window',function($scope,$http){
$scope.formdata = {
"questionnaire":[
{
"questionReference":"RECENCY",
"answer":"Rec001"
},
{
"questionReference":"CONSOLIDATION",
"answer":"Con001"
},
{
"questionReference":"PERFORMANCE",
"answer":"Per001"
},
{
"questionReference":"QUIZ",
"answer":"Yes"
},
{
"questionReference":"TAX_FREE_CASH",
"answer":"Yes"
}
],
"savingsElsewhere":{
"valueOfPensions":"40000",
"monthlyContributionsToOtherPensions":"4000",
"employerContributionsToOtherPensions":"4000",
"valueOfISAs":"2000",
"monthlyContributionsToOtherISAs":"2000",
"guaranteedIncome":"2000"
},
"personalDetails":{
"dateOfBirth":[
1970,
3,
2
],
"gender":"M",
"grossSalary":"2000",
"retirementAge":"65"
},
"targetRetirementIncome":"2000",
"isa":[
{
"impl":"rrProduct",
"type":"ISA",
"value":"0",
"regularPayment":{
"amount":"0"
}
}
],
"pension":[
{
"impl":"rrProduct",
"value":"0",
"type":"PENSION",
"regularPayment":{
"amount":"0"
}
}
],
"contactDetails":{
"emailAddress":"[email protected]"
},
"contactPreferences":{
"email":true
}
};
$http({
url: 'https://rrx001.test.aegon.co.uk/api/retirement/score/interim/calculate',
method: "POST",
headers:{
"Content-Type":"application/json"},
data: $scope.formdata
})
.then(function(response) {
// success
},
function(response) { // optional
// failed
});
}]);
</script>
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html>
<html>
<head>
<meta name="description" content="Fix Cross Domain Ajax request CORS" />
<meta charset="utf-8">
<script src="http://code.jquery.com/jquery-2.1.0.min.js"><\/script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"><\/script>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" />
<link href='http://fonts.googleapis.com/css?family=Roboto:400,500' rel='stylesheet' type='text/css'>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css" rel="stylesheet">
<title>Fixing Cross Domain Ajax Request</title>
</head>
<body ng-app="myApp">
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<\!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<a class="navbar-brand" href="#">CORS Fix Demo</a>
</div>
</div><\!-- /.container-fluid -->
</nav>
<div class="container">
<div ng-controller="MyCtrl">
<div class="row">
<div class="col-xs-12">
<div class="list-group">
<a href="#" class="list-group-item" ng-repeat="day in days">
<h4 class="list-group-item-heading">{{day.day_of_week}}</h4>
<p class="list-group-item-text">
{{day.condition}} <br />
</p>
</a>
</div>
</div>
</div>
</div>
</div> </script>
<script id="jsbin-source-javascript" type="text/javascript">var myApp=angular.module("myApp",[]);
myApp.config(['$httpProvider', function($httpProvider) {
$httpProvider.defaults.headers.common["X-Requested-With"] = 'XMLHttpRequest';
}]);
myApp.controller("MyCtrl",['$scope','$http','$window',function($scope,$http){
$scope.formdata = {
"questionnaire":[
{
"questionReference":"RECENCY",
"answer":"Rec001"
},
{
"questionReference":"CONSOLIDATION",
"answer":"Con001"
},
{
"questionReference":"PERFORMANCE",
"answer":"Per001"
},
{
"questionReference":"QUIZ",
"answer":"Yes"
},
{
"questionReference":"TAX_FREE_CASH",
"answer":"Yes"
}
],
"savingsElsewhere":{
"valueOfPensions":"40000",
"monthlyContributionsToOtherPensions":"4000",
"employerContributionsToOtherPensions":"4000",
"valueOfISAs":"2000",
"monthlyContributionsToOtherISAs":"2000",
"guaranteedIncome":"2000"
},
"personalDetails":{
"dateOfBirth":[
1970,
3,
2
],
"gender":"M",
"grossSalary":"2000",
"retirementAge":"65"
},
"targetRetirementIncome":"2000",
"isa":[
{
"impl":"rrProduct",
"type":"ISA",
"value":"0",
"regularPayment":{
"amount":"0"
}
}
],
"pension":[
{
"impl":"rrProduct",
"value":"0",
"type":"PENSION",
"regularPayment":{
"amount":"0"
}
}
],
"contactDetails":{
"emailAddress":"[email protected]"
},
"contactPreferences":{
"email":true
}
};
$http({
url: 'https://rrx001.test.aegon.co.uk/api/retirement/score/interim/calculate',
method: "POST",
headers:{
"Content-Type":"application/json"},
data: $scope.formdata
})
.then(function(response) {
// success
},
function(response) { // optional
// failed
});
}]); </script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment