亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為什么提交之后是這樣的?

為什么提交之后是這樣的?

薏苡x 2017-07-26 15:03:37
<%@ page contentType="text/html;charset=UTF-8" language="java" %><html><head> ? ?<title>get</title></head><body><form action=""id="forml"> ? ?<p>評論:</p> ? ?<p>姓名:<input type="text" name="username"id="username"></p> ? ?<p>內容:<textarea name="content" ?cols="30" rows="10"></textarea></p> ? ?<p><input type="button" id="send" value="提交"></p></form><div class="comment">已有評論:</div><div id="resText"></div><script src="static/js/jquery-1.8.3.min.js"></script><script> ? ?$(function () { ? ? ? ?$("#send").click(function () { ? ? ? ? ? ?$.post("get.jsp",{ ? ? ? ? ? ? ? ?username:$("#username").val(), ? ? ? ? ? ? ? ?content:$("#content").val() ? ? ? ? ? ?},function (data,textStatus) { ? ? ? ? ? ? ? ?$("#resText").append(data); ? ? ? ? ? ?}) ? ? ? ?}) ? ?})</script></body></html>
查看完整描述

1 回答

已采納
?
李曉健

TA貢獻1036條經驗 獲得超461個贊

form里應該有一個提交按鈕,也就是type=submit的button; 如果你沒有指定這個type,他就會默認把第一個button當成提交按鈕,當你點擊里他提交form,而你的form的action是空,提交時就相當于提交到當前頁面,也就是刷新頁面。解決方法兩種,一個是在你的點擊事件里阻止form的默認提交,第二個就是最后那個按鈕不要用button,可以用a,a的href="javascript:;"

查看完整回答
反對 回復 2017-07-26
  • 1 回答
  • 0 關注
  • 1671 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號