T
T
tema4you2019-01-09 23:13:52
JSON
tema4you, 2019-01-09 23:13:52

Get request to api ajax from PC is executed but not from the server why?

The essence of the question is as follows...
A script was written to pull data from the JSON
HTML api format for display on the page

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="list" align="left">  
</div>

AJAX GET request to JSON from api
$(document).ready(function(){
  $.getJSON('http://moonwalk.cc/api/videos.json?kinopoisk_id=840884&api_token=5e033f0ca3c444b044dbea6f4648f476', function(data) {
  result='<h3 class="ofilme">Информация о фильме</h3><br><ul class="circle"><li><b class="red">Название: </b>'+data[0].title_ru+"</li><br>"+
  '<li><b class="red">Оригинальное: </b>'+data[0].title_en+"</li><br>"+
  '<li><b class="red">Год: </b>'+data[0].year+"</li><br>"+
  '<li><b class="red">Страна: </b>'+data[0].material_data.countries+"</li><br>"+
  '<li><b class="red">Слоган: </b>'+data[0].material_data.tagline+"</li><br>"+
  '<li><b class="red">Жанр: </b>'+data[0].material_data.genres+"</li><br>"+
  '<li><b class="red">Актёры: </b>'+data[0].material_data.actors+"</li><br>"+
  '<li><b class="red">Режисер: </b>'+data[0].material_data.directors+"</li><br>"+
  '<li><b class="red">Cтудия: </b>'+data[0].material_data.studios+"</li><br></ul>";
      $("#list").html(result);
});
});


JSON output example
[{
    "added_at": "2016-01-19 20:25:09",
    "block": {
      "block_ru": false,
      "block_ua": false,
      "blocked_at": null
    },
    "camrip": false,
    "category": null,
    "directors_version": false,
    "duration": {
      "human": "02:21",
      "seconds": 8479
    },
    "iframe_url": "http://moonwalk.cc/video/7f226d3f983ad2c9/iframe",
    "instream_ads": false,
    "kinopoisk_id": 840884,
    "material_data": {
      "actors": ["Том Хэнкс", "Марк Райлэнс", "Эми Райан", "Алан Алда", "Остин Стоуэлл", "Скотт Шеперд", "Джесси Племонс", "Доменик Ломбардоззи", "Себастьян Кох", "Ив Хьюсон"],
      "age": 16,
      "countries": ["США", "Германия", "Индия"],
      "description": "Действие фильма происходит на фоне серии реальных исторических событий и рассказывает о бруклинском адвокате Джеймсе Доноване, который оказывается в эпицентре холодной войны, когда ЦРУ отправляет его на практически невозможное задание - договориться об освобождении захваченного в СССР американского пилота самолета-разведчика U2.",
      "directors": ["Стивен Спилберг"],
      "genres": ["триллер", "драма", "история"],
      "imdb_rating": 7.6,
      "imdb_votes": 244601,
      "kinopoisk_rating": 7.481,
      "kinopoisk_votes": 80289,
      "mpaa_rating": 0.0,
      "mpaa_votes": 0,
      "poster": "https://st.kp.yandex.net/images/film_iphone/iphone360_840884.jpg",
      "studios": ["Amblin Entertainment", "DreamWorks SKG", "Fox 2000 Pictures", "Marc Platt Productions", "Participant Media", "Reliance Entertainment", "Studio Babelsberg", "TSG Entertainment"],
      "tagline": "«Когда мир на грани войны, лишь честь одного человека может предотвратить катастрофу»",
      "updated_at": "2019-01-09 02:49:12",
      "year": 2015
    },
    "pornolab_id": null,
    "source_type": null,
    "title_en": "Bridge of Spies",
    "title_ru": "Шпионский мост",
    "token": "7f226d3f983ad2c9",
    "trailer_iframe_url": "https://trailerclub.me/video/467800d915d2ad44/iframe",
    "trailer_token": "467800d915d2ad44",
    "translator": "Дубляж",
    "translator_id": 21,
    "type": "movie",
    "world_art_id": null,
    "year": 2015
  }
]

So, if I execute my script from my home PC, all the data is easily pulled out and placed on the page in the divs I need ...
But as soon as I upload the site to the host, I mysteriously get a donut hole, in other words, an empty page.

Tell me how to deal with this? what to do? Other solutions to the problem...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Shumov, 2019-01-10
@inoise

Open the browser console. Swears at CORS?)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question