1
MVC4 웹 API를 배우려고합니다. VS2010 자체에서 프로젝트를 실행하고 있습니다.프로젝트 외부의 일반 HTML 파일에서 MVC4 웹 API 호출
내 프로젝트 URL은 localhost입니다 : 31,735
직접 브라우저 자체에서 WebAPI를 호출. localhost와 같이 작동합니다 : 31735/api/products/
이제 프로젝트 외부의 일반 HTML 파일에서 Webapi를 호출하려고합니다.
나는이$(document).ready(function() {
// Send an AJAX request
$.getJSON("http://localhost:31735/api/products/",
function (data) {
// On success, 'data' contains a list of products.
$.each(data, function (key, val) {
// Format the text to display.
var str = val.Name + ': $' + val.Price;
// Add a list item for the product.
$('<li/>', { html: str }).appendTo($('#products'));
});
});
});
을하려고 노력하지만이 작업을 doesnot. 도울 수 있니.
고마워요. 그것은 효과가 있었다. –