日期:2014-05-17  浏览次数:20660 次

求JQuery Ajax实例,有点蒙
求 JQuery Ajax实例

------解决方案--------------------
给个例子

function checkName(userName){
$.ajax({
url:../user/checkUser.action,//请求路径
  data:{userName:userName},//需要的参数
  success:function(data){//返回
if(data=="true"){//返回字符类型(json也可以)
alert("已经存在");
}
}
});
}

//后台
获取参数验证,验证返回字符类型的true或者false;

------解决方案--------------------
给你一个详细点的例子
jsp:
<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s"  %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--框架必需start-->
<script type="text/javascript" src="../js/jquery-1.4.js"></script>
<script type="text/javascript" src="../js/framework.js"></script>
<link href="../css/import_basic.css" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" type="text/css" id="skin"/>
<!--框架必需end-->

<!--让ie6支持透明png图片start-->
<script type="text/javascript" src="../js/method/pngFix/supersleight.js"></script>
<!--让ie6支持透明png图片end-->
<script type="text/javascript">
function deleteB(id){
alert(id);
top.Dialog.confirm("是否确认删除该条记录?",function(){
$.post(
"deletebusiness.action",
{"id":id},
function (data){
if(data.ok){
history.go(0);
window.top.frmleft.location="businesscount.action";
top.Dialog.alert("删除成功!");
}else{
top.Dialog.alert("系统错误,请重试!");
}
},
"json"
);
});
}
function xiugai(id){
top.Dialog.open({URL:"lesson/business.action?id="+id,Title:"修改信息",Width:800,Height:600});
}
function chakan(id){
top.Dialog.open({URL:"lesson/chakanbusiness.action?id="+id,Title:"业务信息",Width:800,Height:600});
}
function daochuexcel(){