Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How do you log out with java script

This is the code I have along with the errors I get with both vue router and regular ajax:


doRequest: function (url, method, successCb, errorCb, params, conf) {

    var pms = [];

    if (typeof params === 'object') pms = params;

        function callback(body) {

            console.log(body);

            return [];

        }

        var httpCong = {

            url: url,

            method: method,

            crossDomain: true,

            data: params

        };


        if (pms !== null && typeof pms === 'object') {

            if (Object.keys(pms).length > 0) {

            httpCong['processData'] = true;

        }

    }

    if (typeof conf === 'object') {

        if (typeof conf.dataType !== 'undefined') {

            httpCong['dataType'] = conf.dataType;

        }

    }


    var request = $.ajax(httpCong);

    request.done(function(body) {

    self.doingAction = false;


    var out = {body: body};


    if (!body) out['data'] = [];

    else out['data'] = JSON.parse(body);


    if (successCb) successCb(out);

       self.doingAction = false;

   });


    request.fail(function(body) {

        var out = {body: body};

        out['data'] = JSON.parse(body);

        if (errorCb) errorCb(out);

        self.doingAction = false;

    });



this.$http.delete('https://ip/dev-test/qps/user?QlikTicket=' + this.qlikTicket, {

       headers: {

           'Access-Control-Allow-Origin': 'http://13.81.124.229'

       }

  })

  .then(function (response) {

       console.log('response: ', response);

    },

    function (error) {

       console.log('ERROR: ');

       console.log(error);

    }

)

this.doRequest('https://ip/qps/dev-test/session/' + this.qlikTicket, 'delete',

//this.doRequest('https://ip/dev-test/qps/user', 'delete',

    function (res) {

        console.log('response: ', res);

    },

    function (error) {

        console.log('ERROR: ');

        console.log(error);

    },

    null,

    {

    //dataType: "jsonp"

    })

;

Errors:

XMLHttpRequest cannot load https://ip/qps/dev-test/session/_Bszur-jQsCMNSzj. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8000' is therefore not allowed access.

VM40803:1 Uncaught SyntaxError: Unexpected token o in JSON at position 1

    at JSON.parse (<anonymous>)

    at Object.<anonymous> ((index):961)

    at j (require.js?QlikTicket=_Bszur-jQsCMNSzj:12)

    at Object.fireWith [as rejectWith] (require.js?QlikTicket=_Bszur-jQsCMNSzj:12)

    at d (require.js?QlikTicket=_Bszur-jQsCMNSzj:13)

    at XMLHttpRequest.<anonymous> (require.js?QlikTicket=_Bszur-jQsCMNSzj:13)

(anonymous) @ (index):961

j @ require.js?QlikTicket=_Bszur-jQsCMNSzj:12

fireWith @ require.js?QlikTicket=_Bszur-jQsCMNSzj:12

d @ require.js?QlikTicket=_Bszur-jQsCMNSzj:13

(anonymous) @ require.js?QlikTicket=_Bszur-jQsCMNSzj:13

ip/dev-test/qps/user?QlikTicket=_Bszur-jQsCMNSzj:1 DELETE https://ip/dev-test/qps/user?QlikTicket=_Bszur-jQsCMNSzj 500 (Internal server error)

doRequest with json P to the first URL error:

VM41904:1 Uncaught SyntaxError: Unexpected token o in JSON at position 1

    at JSON.parse (<anonymous>)

    at Object.<anonymous> ((index):961)

    at j (require.js?QlikTicket=ayllZsvuxMkBQnr4:12)

    at Object.fireWith [as rejectWith] (require.js?QlikTicket=ayllZsvuxMkBQnr4:12)

    at d (require.js?QlikTicket=ayllZsvuxMkBQnr4:13)

    at HTMLScriptElement.c (require.js?QlikTicket=ayllZsvuxMkBQnr4:13)

    at HTMLScriptElement.dispatch (require.js?QlikTicket=ayllZsvuxMkBQnr4:12)

    at HTMLScriptElement.q.handle (require.js?QlikTicket=ayllZsvuxMkBQnr4:12)

doRequest with json P to the second URL error:

Uncaught SyntaxError: Unexpected token :

VM42557:1 Uncaught SyntaxError: Unexpected token o in JSON at position 1

    at JSON.parse (<anonymous>)

    at Object.<anonymous> ((index):961)

    at j (require.js?QlikTicket=J4W1Bls5CU_S79LS:12)

    at Object.fireWith [as rejectWith] (require.js?QlikTicket=J4W1Bls5CU_S79LS:12)

    at d (require.js?QlikTicket=J4W1Bls5CU_S79LS:13)

    at HTMLScriptElement.c (require.js?QlikTicket=J4W1Bls5CU_S79LS:13)

    at HTMLScriptElement.dispatch (require.js?QlikTicket=J4W1Bls5CU_S79LS:12)

    at HTMLScriptElement.q.handle (require.js?QlikTicket=J4W1Bls5CU_S79LS:12)

0 Replies