fuck-cors/index.html
2014-09-26 15:51:51 +02:00

51 lines
1.3 KiB
HTML

<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
var murl="http://m4.vigiglo.be:3000/api";
function getMe(){
$.ajax(
{url: murl + "/resources/whoami"
, type: 'GET'
, success: function(data){alert(data)}
, error: function(data,status){alert("WHOAMI ERROR: " + status);}
});
}
function login(next){
$.ajax(
{url: murl + "/login"
, type: 'GET'
, data: {username: 'teser@test.com', password: 'test'}
, success: getMe
, error: function(data,status){alert("LOGIN ERROR: " + status);
next();
}
, xhrFields: { withCredentials: true }
, crossDomain: true
});
}
function argh(pref){
return function(data,status){
alert(pref + ": " + data.toString());
alert(pref + ": " + status.toString());
};
}
function logout(next){
$.ajax(
{url: murl + "/logout"
, type: 'GET'
, success: next
, error: argh("logout")
, xhrFields: { withCredentials: true }
, crossDomain: true
});
}
$(document).ready(function(){
logout( function(){login ( getMe )} );
});
</script>
</head>
<body>
HERE
</body>
</html>