I want to write json api response like below into html code
{
"status": 200,
"message": "OK",
"data": {
"total": 5
}
}
When I create js file to get the response, the result is empty. I have checked console mode on browser and find the warning like below
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://url-api. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
Here's the javascript code
$(function ()
{
$.ajax({
url: 'https://url-api',
type: 'GET',
dataType: 'json',
success: function (data) {
//append each row data to datatable
var data = +data.total;
document.getElementById("total").innerHTML = data;
}
});
})
Here's the html code
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="script.js"></script>
<div class="inner">
<h3 id="total"></h3>
<p>Total</p>
</div>
Do you know how to show the data total that I want from the api ?
Thank you