2014-01-13 5 views
0

크롬 개발자 도구가 요청에 대한 응답을 표시한다는 사실에도 불구하고 왜 성공 메서드가 실행되지 않는지 알 수없는 간단한 아약스 호출이 있습니다.jquery ajax success not working

$(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); 
     } 

    }); 
}); 
+0

json –

+0

으로 답장을 보내시겠습니까? ur 브라우저에서 http://moviesapi.herokuapp.com/cinemas/find/PL15RH를 입력하여 응답을 확인할 수 있습니다. –

+0

API는 jsonp –

답변

1
  1. 이 API는 JSONP를 지원하지 않습니다. 500 (Internal Server Error)이 표시됩니다.

  2. JSON을 지원하지만 고전적인 No 'Access-Control-Allow-Origin' header is present on the requested resource CORS 오류가 발생합니다.

헤더 속성 : 당신은 명시 적으로 Heroku가의 API에 Access-Control-Allow-Origin 헤더를 보낼 필요가

Access-Control-Allow-Origin: * 

더 자세한 솔루션 : "No 'Access-Control-Allow-Origin' header is present on the requested resource"

+0

나는 그것을 시도했다. –

+0

분명히 CORS 오류가 발생하기 때문이다. – brandonscript

+0

아니 전혀 오류를 던지지 않고 –

0

이 시도 :

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); 
     } 

    }); 
}); 
+0

나는 작동하지 않았다. –

0

은 시간이 걸렸습니다하지만 나

근무 크로스 도메인은 아래의 코드를 잘 붙여서 작동합니다 &

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

     complete: function (response) {    
     alert(1); 
    } 

    }); 
}); 

존경받는 사람에게 줄을주십시오. 도움이 필요하면

+0

경고가 실행되지 않습니다. 다시 테스트하십시오. –

+0

jsonp를 다시 jsonp로 변경했습니다. – sanjeev

+0

@imran jawaid – sanjeev