0
I am trying to request a third party API through the following code:
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.3.1.min.js"></script>
<script>
$(function(){
$.post({
url: url,
contentType: "application/json;",
data:"1",
headers: {'Authorization': 'Basic token'},
success: function(data) {
console.log(data)
}, error: function(err) {
console.log('error')
}
});
});
</script>
But I am returning the following message.
Mixed Content: The page at 'link-host' was Loaded over HTTPS, but requested an insecure Xmlhttprequest endpoint 'link-api'. This request has been blocked; the content must be served over HTTPS.
How to solve this problem? Through PHP I managed to make the request.
If your page contains SSL, then the request link must be SSL (https). In the PHP this is can be ignored, so it works. There is a gambiarra that you can do: Just create a file
api.php
and use thecURL
to send the data to (third-party) API, receive the content, treat and display to the user.– Valdeir Psr
I have to do only with JS =/
– Antonio Pedro