//总结经验: Json 比dwr 用法好 dwr会将方法都暴漏在外面
1>Action层
public void dismissalTeacherOperation(){
String status = null;
boolean flag = false;
String[] cardIdStr = cardId.split(",");
String employId = cardIdStr[0];
String employStatus = cardIdStr[1];
if(employStatus.equals(Constants.EMPLOY_TEACHER_STATUS_NO)){
flag = employManager.dismissalTeacher(employId);
if(flag){
status = "{msg:'"+Constants.EMPLOY_TEACHER_STATUS_NO+"'}";
}else{
status = "{msg:'"+Constants.EMPLOY_TEACHER_STATUS_YES+"'}";
}
}
JSONObject jsonObject = JSONObject.fromObject(status);
this.sendCallBackValue(jsonObject.toString());
}
public void sendCallBackValue(String content){
HttpServletResponse response = this.getResponse();
try {
response.getWriter().write(content);
} catch (IOException e) {
e.printStackTrace();
}
}
2>jsp页面
function employ(employId,employStatus,index){
var status=employStatus
var employCardId=employId+','+status;
document.selectEmployForm.divNum.value=index;
if(confirm("<s:text name='employ.judgeResult.shureEmploy'/>")){
jQuery.ajax({
url:"/eitp/employ/judgeResultOperation.html",
data:{cardId:employCardId},//传递参数
type : "post",
cache : false,
dataType : "json",
success:callback
});
}
return false;
}
function callback(data){
var index = document.selectEmployForm.divNum.value
var status = data.msg;//从action中传过来的状态值
var divStatusNum = "status"+index;
var emyployYesNum = "emyployYes"+index;
var employNoNum = "emyployNo"+index;
if(status==0){
document.getElementById(divStatusNum).innerHTML="<font color=\"green\"><s:text name='employ.judgeResult.employOffer'/></font>";
document.getElementById(emyployYesNum).innerHTML="<font color=\"#999999\"><s:text name='employ.judgeResult.employYes'/></font>";
document.getElementById(employNoNum).innerHTML="<font color=\"#999999\"><s:text name='employ.judgeResult.employNo'/></font>";
alert('<s:text name="employ.judgeResult.employOffer"/>');
}else if(status==4){
alert('<s:text name="employ.judgeResult.notEmployForNoAnsQuestion"/>');
}else if(status==5){
document.getElementById(divStatusNum).innerHTML="<font color=\"red\"><s:text name='employ.judgeResult.employNo'/></font>";
alert('<s:text name="employ.judgeResult.employNo"/>');
}else if(status==6){
alert('<s:text name="employ.judgeResult.priorEmploy"/>');
}
}
需要导
<script type="text/javascript" src="/eitp/scripts/jquery/jquery-1.3.2.js"></script>
<script type="text/javascript" src="/eitp/scripts/jquery/json2.js"></script>
//dwr
在dwr.xml中配置
<create creator="spring" javascript="moreScale"> 导包时名字要与此一至
<param name="beanName" value="moreScaleManager"/> 接口
<include method="scale"/> 接口中的方法名
</create>
在application.service.xml中配置
在页面中调用
moreScale.scale(chooseOrderId,function(qb){
var status = qb.answerStatus;
if(status==2){
alert('<s:text name="test.sacle.no"/>');
}else{
window.open ('/eitp/test/viewScales.html?infoId='+chooseOrderId+'&scaleTemp='+scaleTemp, 'newwindow', 'height=400, width=600,
top=100, left=100, toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes,location=no, status=no');
}
});
导包
<script type="text/javascript" src="<s:url value='/dwr/interface/moreScale.js' />"></script>
<script type="text/javascript" src="<s:url value='/dwr/engine.js'/>"></script>
分享到:
相关推荐
jQuery ajax 无刷新 验证码 asp.net
jquery+ ajax 实现的一个无刷新的MD5加密案例,前台输入需要加密的值,通过ajax获取加密后的值
jQueryAjax动态刷新技术,该文件是让你如何了解jQuery的动态刷新功能的,值得一看哦!
多个采用 jquery+Ajax无刷新交互的方式来实现的评论留言实例,欢迎下载。
使用 Ajax + JQuery 实现无刷新效果,提高用户的视觉效果。
PHP+jQuery ajax无刷新上传图片 带上传进度条。代码无加密,可二次开发,默认自带样式,很方便修改样式。 自带demo.
Ajax无刷新分页Jquery 可以设置自己的分页样式,利用ashx接受事件请求,值得一学
JqueryAjax 无刷新分页 带数据库 直接可运行 pageTest.asp js封装 简化代码
ASP实例开发源码—jQuery AJAX无刷新评论.zip ASP实例开发源码—jQuery AJAX无刷新评论.zip ASP实例开发源码—jQuery AJAX无刷新评论.zip
jquery+jquery.uploadify.js插件,实现无刷新上传文件 支持ie6,模拟进度条(模拟进度条,非正式进度) 无刷新上传 ashx处理.
jqueryAjax_无刷新调用另一页实例 要放在asp,jsp ,php 运行环境里
jquery+ajax实现无刷新提交的功能。
自己写的,用jquery 实现解析xml文件的ajax 无刷新的分页技术,每页的条数随你设置,有校验的。
基于PHP的jqueryajax无刷新评论 无刷新翻页,字数统计 绝对可以用.zip
实现了获取评论无刷新,发表评论无刷新,www.sendawangluo.com页面获取评论时显示loading加载效果jquery真的是一个非常优秀的JS库,简单容易掌握,对于网页中的多级菜单、级联效果、Tab选项卡切换、图片轮转显示,...
基于PHP的jqueryajax无刷新评论无刷新翻页,字数统计绝对可以用源码.zip
jQuery_AJAX 无刷新评论功能代码
jQuery+Json 实现Ajax无刷新分类管理实例演示 基于jquery+json实现的网站后台管理中无刷新的分类管理功能演示,如上...相当不错的Json学习资料,也是ASP.NET结合jQuery实现Ajax无刷新操作技术的典型实例,有必要借鉴。
php代码用的文件上传代码 使用jQuer类库,Ajax upload 插件,实现ajax 无刷新上传,