I'm trying to execute a Swagger request using Ajax. But it doesn't work.

It works when using an Rest client for test (I get the respons correctly) but doesn't work with ajax

Here is the jquery code I used (the token key is not complete) :

function get_test() {

alert('okey');

$.ajax({


     type : 'GET',
     url: 'https://mawaqit.net/api/1.0.0/hadith/random?lang=%22ar%22',
      headers: { 'Api-Access-Token': 'fbeeed52-5ed0-4f48-89e7-xxxxx'},
      dataType: "text",
      success: function(response)
        {
             //var data = JSON.parse(response);

            alert('ok');


        },

        error : function(jqXHR, textStatus, errorThrown){

           console.log('jqXHR:');
            console.log(jqXHR);
            console.log('textStatus:');
            console.log(textStatus);
            console.log('errorThrown:');
            console.log(errorThrown.status);

   }

    });             



}

0 Answers