我的查询
let name = document.getElementById("Name").value;
let code = document.getElementById("Code").value;
let type = document.getElementById("ProductTypeId").value;
$.ajax({
url: "/Home/jQueryAddComment",
type: "POST",
dataType: "html",
data: json,
success: function(data){
//var message = data.Message;
alert(data);
$('.CommentSection').html(data);
}
}
我需要使用 fetch 将我的 jQuery 转换为纯 Javascript 函数。它是一个带有html返回的post方法。是否可以使用 fetch.
编辑:下面是我的 Javascript 的 get 方法:
fetch(url + "?" + o)
.then(function (response) {
//check if it is redirected to custom error page
if (response.redirected && response.url.indexOf("/Error") > 0) {
response.text().then(function (html) {
debugger
window.location.href = response.url;
});
} else {
response.text().then(function (html) {
document.getElementById('view-all').innerHTML = html;
});
}
})
.catch(function (err) {
console.log('Fetch Error', err);
});
RISEBY
相关分类