У меня есть GET API, который дает мне следующий результат:
![enter image description here](https://i.stack.imgur.com/oW7kg.png)
Следующий код пытается получить эту информацию JSON:
<script>
jQuery(document).ready(function ($)
{
$.ajax({
url: 'http://localhost:15840' + '/totem/GetRestaurants',
type: "GET",
dataType: "jsonp",
crossDomain: true,
complete: function (data)
{
alert (data)
for (var restaurant in data)
{
document.getElementById('restaurants').innerHTML = '<li class="gallery-image" > <a href="3.html" class="thumb"><img src="img/restaurante-02.jpg" alt="" /><div class="gallery-text"><span>FOOD RESTAURANT</span></div></a></li >'
}
},
error: function () {
alert("error");
}
});
});
</script>
Метод ошибки всегда выполняется, и полное оповещение просто отображает следующую информацию:
![enter image description here](https://i.stack.imgur.com/G7TFf.png)
Но если я перехожу на ChromeИнспектор, ответ выглядит хорошо:
![enter image description here](https://i.stack.imgur.com/O6qLs.png)
![enter image description here](https://i.stack.imgur.com/rkPy6.png)
Почему это происходит?
РЕДАКТИРОВАТЬ:
С помощью следующего кода ничего не происходит:
<script>
jQuery(document).ready(function ($)
{
$.ajax({
url: 'http://localhost:15840' + '/totem/GetRestaurants',
type: "GET",
dataType: "jsonp",
crossDomain: true,
success: function (data)
{
alert ("hello success")
}
});
});
</script>