JQuery中使用a-jax局部书刷新验证表单
来源:互联网 发布:手机淘宝怎么看优惠券 编辑:程序博客网 时间:2024/04/30 11:16
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript" src="js/jquery-1.7.1.js"></script>
<script type="text/javascript">
/*$(function(){
$("#ac").blur(function(){
var userNo = $(this).val();
$.post("test","userNo="+userNo,function(response){
$("#shit").text(response);
});
});
});*/
$(function(){
$("#ac").blur(function(){
var userNo = $(this).val();
$.get("test?userNo="+userNo,null,function(response){
$("#shit").text(response);
});
});
});
</script>
</head>
<body>
<form action = "#" method = post>
账号:<input name="account" id="ac">
<div style="display:inline" id="shit"></div>
<br/>
<input type="submit" />
</form>
</body>
</html>
==============================servlet:=======================================
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class test extends HttpServlet {
/**
* Constructor of the object.
*/
public test() {
super();
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=utf-8");
PrintWriter out = response.getWriter();
String temp = request.getParameter("userNo");
if(temp.equals("zhangsan")){
out.println("账号可用");
}else{
out.println("账号不可用");
}
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=utf-8");
PrintWriter out = response.getWriter();
String temp = request.getParameter("userNo");
if(temp.equals("zhangsan")){
out.println("账号可用");
}else{
out.println("账号不可用");
}
}
}
=====================================
jQuery.get(url, [data], [callback], [type])
jQuery.post(url, [data], [callback], [type])
url:发送请求地址。
data:待发送 Key/value 参数。
callback:发送成功时回调函数。
type:返回内容格式,xml, html, script, json, text, _default。
- JQuery中使用a-jax局部书刷新验证表单
- jquery中使用get实现局部刷新
- 使用jQuery实现Ajax异步提交表单实现局部刷新
- ajax、jquery、jquery模板实现异步表单,局部刷新
- 使用js局部刷新验证码
- 使用jQuery验证用户名是否存在,达到局部刷新的效果
- 使用jQuery验证用户名是否存在,达到局部刷新的效果
- jQuery实现Ajax异步提交表单实现局部刷新
- JQuery的AJAX局部刷新使用操作
- jquery中validation表单验证
- JQuery使用表单验证空间
- 使用jQuery进行表单验证
- jQuery中使用ajax对表单数据进行异步验证
- struts2+json+jquery局部刷新实现注册验证
- 局部刷新验证码
- 局部刷新验证码
- 在ASP.NET MVC中使用Jquery实现页面局部刷新
- jQuery 定时局部刷新
- 接口Iterator
- Header详解
- 脱壳
- 第六周项目(3):括号的匹配
- 《TCP/IP高效编程》 ---------阅读笔记
- JQuery中使用a-jax局部书刷新验证表单
- SQL Server之存储过程基础知识
- xcode编程中使用使用了DOUAudioStreamer这个第三方遇到的问题及其解决方法
- Java中泛型的理解(二)
- Codeforces Round #324 (Div. 2) B. Kolya and Tanya(组合数学)
- Handler自我理解
- acmPOJ--3615
- python爬虫程序,由根目录一直爬各个网址
- 女程序猿到此一游