I am trying to learn the MVC4 web API. I am starting my project from VS2010.
My project url is localhost: 31735
When calling WebAPI directly from the browser itself. It works as localhost: 31735 / api / products /
Now I want to call Webapi from a regular HTML file outside the project.
I tried to do it
$(document).ready(function () {
$.getJSON("http://localhost:31735/api/products/",
function (data) {
$.each(data, function (key, val) {
var str = val.Name + ': $' + val.Price;
$('<li/>', { html: str }).appendTo($('#products'));
});
});
});
But that does not work. You can help.
source
share