Jquery Ajax 使用备忘
2016-04-20 14:12
363 查看
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% 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"> <script type="text/javascript" src="ext/jquery-1.9.1.min.js"></script> <script type="text/javascript"> function ajaxSubmit() { $.ajax({ url : "http://localhost:8080/RESTfulWSDemo/services/helloWorld", //请求的url地址 dataType : "json", //返回格式为json async : true, //请求是否异步,默认为异步,这也是ajax重要特性 data : { "username" : "Ajax提交请求" }, //参数值 type : "get", //请求方式 cache: false, dataType:'html', beforeSend : function() { //请求前的处理 alert("请求前"); }, success : function(data) { alert(data); //请求成功时处理 alert("成功"); }, complete : function() { //请求完成的处理 alert("完成"); }, error : function() { //请求出错处理 alert("错误"); } }); } </script> </head> <body> This is my JSP page. <br> <form action=""> <input type="button" onclick="ajaxSubmit();" value="提交"> </form> </body> </html>
相关文章推荐
- 一行jQuery全选全不选
- JQuery常用方法(均实践过)
- jQuery基础
- 实践实践(dom)jQuery属性操作
- jQuery Validate插件使用
- jQuery之对话框
- jQuery导入Eclipse后报错解决方法
- JQuery预览图片
- Jquery点击发送按钮后,按钮文本倒计时
- JQuery的silder代码
- JQuery中toggle被淘汰后的替代方法
- JQuery中使用ajax $.ajax()
- DOM文档加载顺序
- Spring MVC中通过Jquery低版本的ajax传递参数值 遇到415的错误
- 深入理解JQuery插件开发
- 十条jQuery代码片段助力Web开发效率提升
- 对于jQuery中事件绑定的一点说明
- jQuery中iframe的操作(点击按钮新增窗口)
- jQuery Ajax 实例 ($.ajax、$.post、$.get)
- Jquery五角星评分效果