国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > AJAX > 正文

解決ajax返回驗證的時候總是彈出error錯誤的方法

2024-09-01 08:28:09
字體:
來源:轉載
供稿:網友

發一個簡單案例:
前臺:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html>  <head>    <title>用戶登錄</title>    <script type="text/javascript" src="../js/jquery-easyui-1.3.5/jquery.min.js"></script>    <script type="text/javascript" src="../js/jquery-easyui-1.3.5/jquery.easyui.min.js"></script>    <link rel="stylesheet" href="../js/jquery-easyui-1.3.5/themes/default/easyui.css" type="text/css"></link>    <link rel="stylesheet" href="../js/jquery-easyui-1.3.5/themes/icon.css" type="text/css"></link>    <script type="text/javascript" src="../js/jquery-easyui-1.3.5/locale/easyui-lang-zh_CN.js"></script>    <meta http-equiv="content-type" content="text/html;charset=UTF-8" />    <script type = "text/javascript" charset = "UTF-8">    $(function(){      var loginDialog;      loginDialog = $('#loginDialog').dialog({        closable : false , // 組件添加屬性:讓關閉按鈕消失        //modal : true, //模式化窗口        buttons : [{          text:'注冊',          handler:function(){                      }        },        {          text:'登錄',          handler:function(){             $.ajax({              url:'../servlet/Login_Do',              data :{                 name:$('#loginForm input[name=name]').val(),                 password:$('#loginForm input[name=password]').val()                },              dataType:'json',              success:function(r){               //var dataObj=eval("("+data+")");                alert("進來了");              },              error:function(){                alert("失敗");              }                            });             //alert(data)          }        }]      });    });    </script>   </head>  <body style=”width:100%;height:100%;" >     <div id = "loginDialog" title = "用戶登錄" style = "width:250px;height:250px;" >       <form id = "loginForm" method = "post">         <table>         <tr>           <th>用戶名 :</th>           <td><input type = "text" class = "easyui-validatebox" data-options="required:true" name = "name"><br></td>         </tr>         <tr>           <th>密碼: </th>           <td> <input type = "password" class = "easyui-validatebox" data-options="required:true" name = "password"><br></td></td>         </tr>         </table>       </form>      </div>  </body> </html> 

 后臺:

public class Login_Do extends HttpServlet {   public void doGet(HttpServletRequest request, HttpServletResponse response)       throws ServletException, IOException {       this.doPost(request, response);   }   public void doPost(HttpServletRequest request, HttpServletResponse response)       throws ServletException, IOException {     request.setCharacterEncoding("UTF-8");      response.setCharacterEncoding("UTF-8");     String name =request.getParameter("name");     String password = request.getParameter("password");     String js = "{/"name/":name,/"password/":password}";     PrintWriter out = response.getWriter();     JSONObject json = new JSONObject();     json.put("name",name);     out.print(json.toString());     response.getWriter().write(json.toString());   } }            
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 崇文区| 友谊县| 珲春市| 沿河| 上虞市| 新泰市| 遂溪县| 阿尔山市| 天等县| 阿巴嘎旗| 灌南县| 平顶山市| 贵港市| 澎湖县| 清丰县| 新津县| 洛浦县| 额尔古纳市| 哈巴河县| 荥阳市| 库伦旗| 乐至县| 九江县| 阿克苏市| 万盛区| 天台县| 祁东县| 稻城县| 翼城县| 开原市| 濮阳市| 莲花县| 宁波市| 福鼎市| 开化县| 阜平县| 郁南县| 镇安县| 岳西县| 嘉峪关市| 蓬莱市|