0

I got simple ajax call i could not get why it is not running success method despite the fact that chrome developer tools show that it is getting the response for the request.

$( document ).ready(function() {
    var url_API="http://moviesapi.herokuapp.com/cinemas/find/"+"PL15RH";
    $.ajax({
        type: 'GET',
        url: url_API,
        dataType: "jsonp",
        crossDomain:true,
        success: function (response) {             
            alert(1);
        }

    });
});
Saranya
  • 1,988
  • 16
  • 20
Imran Jawaid
  • 471
  • 1
  • 10
  • 27

2 Answers2

1
  1. The API doesn't support jsonp. You're getting 500 (Internal Server Error).

  2. It does support JSON, but you're getting the classic No 'Access-Control-Allow-Origin' header is present on the requested resource CORS error. You need to explicitly send the Access-Control-Allow-Origin header on your heroku API:

Header property:

Access-Control-Allow-Origin: *

A more verbose solution: "No 'Access-Control-Allow-Origin' header is present on the requested resource"

Community
  • 1
  • 1
brandonscript
  • 68,675
  • 32
  • 163
  • 220
0

try this:

    jQuery(document).ready(function($) {
        var url_API="http://moviesapi.herokuapp.com/cinemas/find/"+"PL15RH";
        $.ajax({
           type: 'GET',
           url: url_API,
           dataType: "json",
           crossDomain:true,
           success: function (response) {             
            alert(response);
        }

    });
});
ReNiSh AR
  • 2,782
  • 2
  • 30
  • 42