Home » Jquery » javascript – Ajax calling an API doesn't work, any solution?

javascript – Ajax calling an API doesn't work, any solution?

Posted by: admin February 22, 2020 Leave a comment

Questions:

enter image description here

I don’t know why that first URL is not working and when I use another one to try it works.

<script>

    $.ajax({
      url: 'http://www.hisnmuslim.com/api/ar/27.json',//this one doesn't,why?

      //url : 'https://jsonplaceholder.typicode.com/users',//this one works 
      contentType: "application/json", 
      dataType: 'json',

      success: function(data) {
        console.log(data);
      },
      error: function(err) {
        console.log(err);
      },
    });
  </script>
How to&Answer: