Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var nid;
- $('#page_dashboard').on('pageshow',function(){
- try{
- $.ajax({
- url:"http://10.0.2.2:81/drupal/services/session/token",
- type:"get",
- dataType:"text",
- error:function (jqXHR, textStatus, errorThrown) {
- // alert(errorThrown);
- },
- success: function (token) {
- // Call system connect with session token.
- $.ajax({
- url: 'http://localhost:81/drupal/test/system/connect.json',
- type: "post",
- dataType: "json",
- beforeSend: function (request) {
- request.setRequestHeader("X-CSRF-Token", token);
- },
- error: function (jqXHR, textStatus, errorThrown) {
- // alert(errorThrown);
- },
- success: function (data) {
- alert('Hello user ' + data.user.name);
- }
- });
- }
- });
- }
- catch(error) { alert("page_dashboard - " + error)};
- });
- $(document).on("click",'#button_logout',function(){
- try {
- $.ajax({
- url: "http://10.0.2.2:81/drupal/test/user/logout.json",
- type: 'post',
- dataType: 'json',
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- alert('button_logout - failed to logout');
- console.log(JSON.stringify(XMLHttpRequest));
- console.log(JSON.stringify(textStatus));
- console.log(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); }
- return false;
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement