This commit is contained in:
Naccl
2023-07-16 00:45:05 +08:00
parent 237b379a08
commit 755fa6ae52
3 changed files with 43 additions and 15 deletions
+20 -12
View File
@@ -29,17 +29,25 @@
$('#generate').click(() => {
let longURL = $('#long').val();
if (longURL) {
$.post("/generate", {
longURL
}, function (res) {
if (res.code === 200) {
$('#short').val(res.data);
} else {
alert(res.msg);
}
}, "json").fail(() => {
alert('异常错误');
});
$.ajax({
url: "/generate",
type: "POST",
contentType: "application/json",
data: JSON.stringify({
longURL: longURL
}),
dataType: "json",
success: function (res) {
if (res.code === 200) {
$('#short').val(res.data);
} else {
alert(res.msg);
}
},
error: function () {
alert('异常错误');
}
});
} else {
alert('请输入原始链接');
}
@@ -54,4 +62,4 @@
});
</script>
</body>
</html>
</html>