Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Zhu yizheng
intern_project_frontend_backend
Commits
dd97b4e5
Commit
dd97b4e5
authored
Jun 25, 2025
by
Zhu yizheng
Browse files
适配后端
parent
943bca90
Changes
2
Hide whitespace changes
Inline
Side-by-side
comment.js
View file @
dd97b4e5
...
...
@@ -23,7 +23,7 @@ submitButton.on('click', function () {
}
$
.
ajax
({
url
:
'
/comment/add
'
,
url
:
'
http://localhost:8080
/comment/add
'
,
method
:
'
POST
'
,
contentType
:
'
application/json
'
,
data
:
JSON
.
stringify
({
name
,
content
}),
...
...
@@ -45,7 +45,7 @@ submitButton.on('click', function () {
// 加载评论
function
loadComments
(
page
)
{
$
.
get
(
'
/comment/get
'
,
{
page
,
size
:
commentsPerPage
},
function
(
res
)
{
$
.
get
(
'
http://localhost:8080
/comment/get
'
,
{
page
,
size
:
commentsPerPage
},
function
(
res
)
{
if
(
res
.
code
===
0
)
{
totalComments
=
res
.
data
.
total
;
displayComments
(
res
.
data
.
comments
);
...
...
@@ -69,8 +69,9 @@ function displayComments(comments) {
deleteButton
.
on
(
'
click
'
,
function
()
{
if
(
!
confirm
(
'
确定删除这条评论吗?
'
))
return
;
$
.
post
(
'
/comment/delete
'
,
{
id
:
comment
.
id
},
function
(
res
)
{
// 修正:将id放在URL的query参数中
$
.
post
(
'
http://localhost:8080/comment/delete?id=
'
+
comment
.
id
,
function
(
res
)
{
if
(
res
.
code
===
0
)
{
alert
(
'
删除成功
'
);
loadComments
(
currentPage
);
...
...
index.html
View file @
dd97b4e5
...
...
@@ -3,6 +3,7 @@
<head>
<meta
charset=
"UTF-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<script
src=
"https://code.jquery.com/jquery-3.7.1.min.js"
integrity=
"sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo="
crossorigin=
"anonymous"
></script>
<link
rel=
"stylesheet"
href=
"style.css"
>
<script
src=
"comment.js"
defer
></script>
<title>
评论区
</title>
...
...
@@ -14,7 +15,7 @@
<h3
class=
"formTitle2"
>
comment content
</h3>
<input
type=
"text"
id=
"comment"
placeholder=
"请输入评论内容"
>
<br>
<button
id=
"submit"
class=
"commo
m
Button"
>
提交
</button>
<button
id=
"submit"
class=
"commo
n
Button"
>
提交
</button>
</div>
<div
class=
"commentsArea"
>
<ul
id=
"commentsList"
></ul>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment