Miomir Dancevic Miomir Dancevic - 3 months ago 29
jQuery Question

Show data from API on page load Jquery

Im trying to display data from API on page load, but i see in network i got a call but the problem is it does not show in HTML, i dont know where can be the problem, this is what i have for now


<div id="models"></div>


var response = "";
$.ajax({ url: "http://carportal.azurewebsites.net/api/portal/brand?CountryCode=RS",
context: document.body,
success: function(){
var json_obj = $.parseJSON(response);
var output="<ul>";
for (var i in json_obj)
output+="<li>" + json_obj[i].Name + "</li>";

Answer Source

you are missing the response parameter in the success function that's why simple as that

success: function(){


success: function(response){


Apart from above the URL throws

Failed to load http://carportal.azurewebsites.net/api/portal/brand?CountryCode=RS: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download