0

I want to get an element of ajax response called url . I tried to run the following code but i get no data back and when i press f12 on firefox i get this error : invalid lable and pointing to status ! could any one tell me how to fix this ajax call?

<div id="phase01"></div>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
  $(document).ready(function() {
    $.ajax({
      dataType: "jsonp",
      url: "http://www.aremotesite.com/episodelink/123456",
      success: function(info){
     alert( info.data.url);
     document.getElementById("phase01").innerHTML = info.data.url ;
    }
   });
  });
</script>

sample data that url link produces when i run on browser:

{
    "status": "OK",
    "message": "Successfull",
    "data": {
        "url": "http:\/\/somesite.com\/vod\/133\/12345\/12345.mp4?md5=Zy9f-dfgdfgdfgfdsdf&expires=234234343432",
        "poster": "http:\/\/somesite\/ok\/images\/lib\/17\/17_243534543_3453454325342543.jpg",
        "title": "episode 10"
    }
}
Munawir
  • 3,346
  • 9
  • 33
  • 51
user1788736
  • 2,727
  • 20
  • 66
  • 110
  • The error message is a little unexpected, but the basic problem is the same as the duplicate. You are telling jQuery to get JSONP and the server is giving you JSON. – Quentin Aug 27 '15 at 11:17
  • Mine is not duplicate is different .so how to show the whole response if i can't reference an specific element from response ? – user1788736 Aug 27 '15 at 11:27
  • "Mine is not duplicate is different" — No, it still looks like a duplicate to me. You'll need to explain what makes it different. Please note my previous comment which explains exactly why it is a duplicate. – Quentin Aug 27 '15 at 11:28
  • "so how to show the whole response if i can't reference an specific element from response" — The problem is that, with your current code, you can't get the response at all. You need to fix that, not try to show different data. – Quentin Aug 27 '15 at 11:29
  • As the answers on the duplicate question say: Either get the server to return JSONP instead of JSON or tell the jQuery to make a request for JSON instead of JSONP. – Quentin Aug 27 '15 at 11:29

0 Answers0