Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).on("click",'#button_logout',function(){
- try {
- $.ajax({
- url:"http://your_url/services/session/token",
- type:"get",
- dataType:"text",
- error:function (jqXHR, textStatus, errorThrown) {
- alert(jqXHR);
- alert(textStatus);
- // alert(errorThrown);
- },
- success: function (token) {
- // Call system connect with session token.
- $.ajax({
- url: "http://your_url/endpoint/user/logout.json",
- type: 'post',
- dataType: 'json',
- beforeSend: function (request) {
- request.setRequestHeader("X-CSRF-Token", token);
- },
- error: function (jqXHR, textStatus, errorThrown) {
- alert('button_logout - failed to logout');
- alert(JSON.stringify(jqXHR));
- alert(JSON.stringify(textStatus));
- alert(JSON.stringify(errorThrown));
- },
- success: function (data) {
- alert("You have been logged out.");
- $.mobile.changePage("index.html",{reloadPage:true},{allowSamePageTranstion:true},{transition:'none'});
- }
- });
- }
- });
- }
- catch (error) { alert("button_logout - " + error); }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement