11 years ago
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: "<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
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: "<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