Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Use .load() in JQuery - URL Problem

Hi guys, I'm trying to experiment new JQuery function and I have problem with .load(). I found it a good alternative for AJAX but I have issue with my url and I can't understand why.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<div id="div">Change me</div>
<div id="text"></div>
<button>Click Me</button>
(function($) {

  var $btn = $('button');
  var $text = $('#text');

  $btn.on('click', function() {
    $(this).hide();
    $text.load('http://idrogeno.xyz/extra/docs/ajax.html');
  });

})(jQuery);

but if I use this URL https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/Bio.txt it works!

someone can understand why?

2 Answers

Steven Parker, I think so too, but I have not idea how to enable that on my hosting. I need contact them and ask more about maybe.

Thank you!

Steven Parker
Steven Parker
242,284 Points

Just a guess, but I'm wondering if you are accessing this page with https and the AJAX attempt using a non-secure protocol is being denied.

well, I tried with the HTTPS protocol too but same issue.

https://jsfiddle.net/coswise/cou61uf9/

Steven Parker
Steven Parker
242,284 Points

It might still be a security issue. Could it be that the URL that works has a valid security certificate, but the other one does not?