I've wrote a snippet for axis room API. While passing the json for testing, I have got Cross-Origin Request Blocked error.
At the same time console shows: {"message":"Could not parse the message.","status":"Error"}
. (see the below image)
I hasn't solution for Cross-Origin Request Blocked error. But now I want to show the Could not parse the message error. How to do that?. Is a good way to solve Cross-Origin Request Blocked error. suggest me please.
My JavaScript code
<script type="text/javascript">
$(function () {
$('#Button1').click(function () {
alert('Alter with jQuery Button Clicked');
alert('Clicked');
$.ajax({
type: 'POST',
url: 'http://test.axisrooms.com/api/daywiseInventory',
data: '{"accessKey": "7eb228097576abf56968e9845ab51b90","channelId": "103","hotels": [{"hotelId": "2","rooms": [ {"roomId": "1", "availability": [ { "date": "2014-05-30","free": 1},{"date": "2014-05-31","free": 1}]}]}]}',
//data: "{accessKey':'cilentAPIKey'}",
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (data) {
callback(data);
alert('sus'+data.toString());
},
error: function (response) {
//alert(response);
//alert('error' + response.valueOf(message));
alert('An error has occured');
}
});
});
});
</script>