Reputation: 297
I have a JS script that post data via AJAX. When I put the script on my server, the posting URL is https but when I view the js via view page source online, the URL starts with http.
I am receiving the below error.
jquery.min.js:4 Mixed Content: The page at 'https://www.mywebsite.com/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://www.mywebsite.com/bookmark'. This request has been blocked; the content must be served over HTTPS.
Script on server
$(document).on("click","#bookmark",function(a){a.preventDefault();var t=$(this).attr("bookmark_id"),e=$("input[name=msmm_tn").val(),s=$(this);$.ajax({type:"POST",url:"https://www.mywebsite.com/bookmark",data:{msmm_tn:e,bookmarkid:t},dataType:"json",success:function(a){"X"==a.status&&(s.find("i").addClass("green"),s.removeAttr("href"))}})})
When I click the js file in my web browser, the https:// is http. I cannot figure out why.
Upvotes: 0
Views: 2614
Reputation: 3613
This error is shown when either website is loaded on "HTTPS:"
and your libraries are loaded on "HTTP:"
OR
This error is shown when either website is loaded on "HTTP:"
and your libraries are loaded on "HTTPS:"
In Codeigniter resolve this by editing "config.php".
Open "application/config/config.php" in your project and change the value of
$config['base_url']
Add "s" in the value
from
$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'];
to
$config['base_url'] = 'https://'.$_SERVER['HTTP_HOST'];
Upvotes: 1