jsp + jquery + json
来源:互联网 发布:抢购软件 编辑:程序博客网 时间:2024/04/30 23:34
<%@ page import="com.qunar.fresh.service.Cookies" %><%@ page import="com.qunar.fresh.dao.UserInfoStrings" %><%@ page contentType="text/html;charset=UTF-8" language="java" %><html><head> <title>update user info</title> <style> body{ width: 100%; position: relative; margin: auto; } h2{ width: 20%; text-align: center; margin: auto; margin-top: 2em; } form{ width: 20%; min-width: 200px; text-align: center; margin: auto; margin-top: 2em; } input{ width: 200px; margin-bottom: 0.5em; } input[type=submit]{ margin-top: 1em; } #feedback_div{ width: 100%; text-align: center; margin: auto; margin-top: 2em; } #feedback{ width: 100%; text-align: center; } a{ color: dodgerblue; } </style> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript"> function getJsonFromInputs(inputArray) { jsonStart = "{"; jsonEnd = "}"; jsonBody = ""; for (index in inputArray) { name = inputArray[index]; value = $("input[name=" + name + "]").attr("value"); console.log(name + ":" + value); jsonBody = jsonBody + "\"" + name + "\"" + ":" + "\"" + value + "\""; if (index != inputArray.length - 1) { jsonBody += ","; } } result = jsonStart + jsonBody + jsonEnd; return result; } function _submit() { $.ajax({ type: "POST", url: "update.json", contentType: "application/json;charset=UTF-8", data: getJsonFromInputs(["user_id", "nickname", "realname", "email"]), dataType: "json", success: function (data) { $("#feedback").html("信息更新成功,点击<a href='/home.jsp'>此处</a>返回。"); } }) } </script></head><body><h2>信息更新</h2><form id="uppdate_form"> <input type="text" name="user_id" readonly ="readonly" value="<% out.print(Cookies.getCookieValue(request,UserInfoStrings.userId)); %>" placeholder="user id"/><br/> <input type="text" name="nickname" placeholder="nickname"/><br/> <input type="text" name="realname" placeholder="real name"/><br/> <input type="email" name="email" placeholder="email"/><br/> <input type="button" value="update" id="update_button" onclick="_submit()"/><br/></form><div id="feedback_div"> <label id="feedback"> </label></div></body></html>
0 0
- Jsp+Servlet+JSON+JQuery
- jsp+jquery+json
- jquery json jsp
- jquery+json+jsp实例
- Jquery json jsp实例
- jsp + jquery + json
- jsp+jquery+ajax+json 实例
- jsp+jquery+ajax+json 实例
- 关于jsp中使用jquery数据格式json
- json+jsp+JQuery 的一个小例子
- jsp+jquery+json+servlet二级联动
- java jsp jquery json 二级联动菜单
- Struts2Action+JQuery+jsp获取json数据
- Jquery+Json+JSP的一个Demo
- 在使用 jquery ajax json jsp 处理数据时出错
- 资费名称唯一性校验(struts2+jsp+json+jquery)
- jsp通过jQuery返回json数据到页面
- jsp 中使用jQuery或者js遍历json数据
- JAVA经典算法32题
- POJ 1442 Black box(单调队列求第k小数)
- 一个iOS 框架介绍:MKNetworkKit
- ubuntu 12.04 安装 openssh-server 失败,请问怎么该弄?
- 只言片语
- jsp + jquery + json
- android系统中Phone类型配置
- POJ--3013--Big Christmas Tree【dijkstra_heap】
- 扩展巴科斯范式(EBNF)
- 反射系数 史密斯圆图
- 如何在eclipse中添加android ADT
- as3扫盲:对象池应用
- Android 软键盘操作
- matlab常用技巧