[Jquery]发送Ajax请求

来源:互联网 发布:python decorator 编辑:程序博客网 时间:2024/05/14 11:42

ajax方式

$.ajax({    async:false, // false为同步, true为异步    type:"POST",    url:"/entity/recruit/recSiteStuManage_checkPrpmsExist.action",     dataType:"json",     data:{  'studentId':studentId,             'siteId':siteId,             'gradeId':gradeId,             'edutypeId':edutypeId,             'orientId':orientId},     success:function(data){            if(data.success == "success") {                    alert("success");            } else {                    alert("failed");            }    },    error:function(data){alert(data.success);}});

++++++++++++++++++++++++++++++++++++++++++++++++++++++++
post方式

$.post(            "/entity/recruit/recSiteStuManage_checkPrpmsExist.action",         {   'studentId':studentId,             'siteId':siteId,             'gradeId':gradeId,             'edutypeId':edutypeId,             'orientId':orientId        },         function(data){                    if(data.success == "success") {                            alert(data.text);                    } else {                            alert(data.text);                    }        },         "json");

++++++++++++++++++++++++++++++++++++++++++++++++++++++++
服务端返回
action:

String ajxResult = "{success : 'success'; msg : '请求成功'}";return "ajxcheck";

jsp:

<%@ taglib prefix="s" uri="/WEB-INF/struts-tags.tld" %><% response.setHeader("expires", "0"); %><s:if test='ajxResult!=null'><s:property value="ajxResult" escape="false"/></s:if><s:else><s:property value="#request.ajxResult" escape="false"/></s:else>
0 0