JSP层

  /*
发送data 主要有三种方式:
1、json 数组(推荐1)
2、url拼接
3、表单的序列化 serialize
*/

<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
$(function(){
$("img").click(function(){
$("input").css("border","3px dotted red");

$.ajax({
url:'B',  //链接的servlet名字
//data:{userName:$('input').val()}, //传输的数据
data:$("input").serialize(),  //表单序列化传输数据
dataType:'text',  //传输的类型
type:'GET',  //传输方式
success:function(result){
alert(result);  //传输成功后 弹个窗
},
error:function(){
alert("发生错误...");  //失败了弹个窗
},
timeout:2000   //设定一个限时标准(超过就报错)
});
});
});
</script>
</head>
<body>
<form id="frm1">
<input type="text" name="userName" value="text文本框" >
<img src="5.jpg">
</form>
</body>

Servlet层

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("访问doGet");
String userName = request.getParameter("userName");
PrintWriter out = response.getWriter();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
out.println("输出数据:"+ userName);
}

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
System.out.println("访问doPost");
PrintWriter out = response.getWriter();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
out.println("在doPost输出数据:");

}

}

Jqueryd的一些 总结的更多相关文章

  1. jqueryd的post传递表单以及取消表单的默认传递

    //取消表单的默认传递: <form method="post" onsubmit="return false;"> 在FORM属性里添加 onsu ...

  2. 扩展jquery的选择器

    I’m sure you all know that it’s possible to create plugins and extend various aspects of the jQuery ...

  3. Ajax 学习笔记

    什么是 AJAX ? AJAX = 异步 JavaScript 和 XML. AJAX 是一种用于创建快速动态网页的技术. 通过在后台与服务器进行少量数据交换,AJAX 可以使网页实现异步更新.这意味 ...

  4. 前端框架-jQuery自学笔记

    What's jQuery jq就是一个封装了很多方法的js库. Why use jQuery 原生js的缺点 不能添加多个入口函数(window.onload),如果添加多个,后面会把前面的覆盖 a ...

随机推荐

  1. CANopen——笔记

    1. c语言的typedef高级用法 typedef void (*post_sync_t)(CO_Data*); http://zhidao.baidu.com/link?url=_lDBGq_uk ...

  2. sql 2005 win7 64 数据引擎

    有个箭头,下拉,选择服务器名(就是本机的名称),如果没有就选择浏览更多,看能搜索出不还没的话就手动输入localhost

  3. robo 3t 在 ubuntu下安装

    如果您尝试安装最新版本robomobo调用可以现在robo3t.或者你尝试在Ubuntu 16.04上安装,按照下面的步骤和你的robomongo安装 下载最新的robomongo tar文件 wge ...

  4. golang中管道热替换

    golang中管道替换问题 https://blog.csdn.net/cyk2396/article/details/78875347 1.运行以下代码: var chan1 chan int va ...

  5. POJ 2104 HDU 2665 主席树 解决区间第K大

    两道题都是区间第K大询问,数据规模基本相同. 解决这种问题, 可以采用平方划分(块状表)复杂度也可以接受,但是实际表现比主席树差得多. 这里大致讲一下我对主席树的理解. 首先,如果对于某个区间[L,R ...

  6. 洛谷P1365 WJMZBMR打osu! / Easy——期望DP

    题目:https://www.luogu.org/problemnew/show/P1365 平方和怎样递推? 其实就是 (x+1)^2 = x^2 + 2*x + 1: 所以我们要关注这里的 x — ...

  7. odb_sqlite_demo

    #include <iostream>       #include <odb/database.hxx>   #include <odb/transaction.hxx ...

  8. 4-2 买家类目-dao(下)

    查询出来的对象ProductCategory就已经有updateTime和createTime了,然而你只是把对象的categoryType给修改了一下,修改之后就执行save方法保存了.所以它还是原 ...

  9. 【转载】DNS原理及其解析过程

    1.在浏览器中输入www.qq.com域名,操作系统会先检查自己本地的hosts文件是否有这个网址映射关系,如果有,就先调用这个IP地址映射,完成域名解析. 2.如果hosts里没有这个域名的映射,则 ...

  10. bzoj 1755: [Usaco2005 qua]Bank Interest【模拟】

    原来强行转int可以避免四舍五入啊 #include<iostream> #include<cstdio> using namespace std; int r,y; doub ...