Ask a Question

RestAPI Ajax using JQuery

kevincoulson
Not applicable

RestAPI Ajax using JQuery

Hi,



I am trying to access the RestAPI using an ajax call but am coming up against issues. Is there any documentation for accessing it this way?



I am currently just trying the log in command but am getting this error: XMLHttpRequest cannot load http://www.alertsite.com/restapi/user/login. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.



I know that this is an issue with CORS but I do not know how to resolve it as I can't find a way to allow CORS on the AlertSite service.



My js is as follows: 




$.ajax({


    type: "POST",


    contentType: "text/xml",



    data&colon; "<Login><Login>[myUsername]</Login><Password>[myPassword]</Password></Login> ",


    dataType: "xml",


    crossDomain: true,


    error: function (jqXhr, textStatus, errorThrown) {


        alert("error");


    },


    success: function (data) {


        alert("success");


    }


});



Any help would be greatly appreciated.



Regards

Kev

1 REPLY 1
TanyaYatskovska
Community Manager

RE: RestAPI Ajax using JQuery

Hi Kevin,

 


I would suggest that you try using the suggestions from this article - they may help you overcome the CORS restriction.

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: