我用MVC创建了Web Api项目。我希望在HTML页面中显示JSON结果。 我该怎么做? 网址:
http://localhost:58379/api/ccpayment/GetEligibility?userid=3830&type=json
我得到的数据采用以下格式
{"DailyAllowance":10000.00,"AmountUsedForTheDay":0.00,"CDF":3.0000,"UserEligibleForCC":"EligibleButBanned"}
答案 0 :(得分:0)
function getYourData() {
$.ajax({
url: "/yourAPI_URL",
data: JSON.stringify({ yourPostDataIfAny }),
type: "Post",
datatype: "json",
contentType: "application/json; charset=utf-8"
}).then(function (data) {
var response = $.parseJSON(data);
//your input field on page
txtAllowance.value = response.DailyAllowance;
});
}