I have a GET API that gives me the following result:
The following code, tries to get this JSON information:
<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>
The error method always get executed, and the complete alert just shows the following information:
But If I go to chrome inspector, the responce looks good:
Why is this happening?
EDIT:
With the following code, nothing happens:
<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>