ajax Sample
ajax script call :
------------------------------------------------------------
<script type="text/javascript" language="javascript">
var clickFlag = false;
function minwonView(requestNo) {
var frm = document.searchForm;
frm.requestNo.value=requestNo;
var userType = '${userType}';
if(clickFlag ==true){
alert("wait");
return;
}
clickFlag =true;
var paramData = $("#searchForm").serialize();
var url = '/test/testMinwon.do';
$.ajax({
url: url,
data: paramData,
type:"POST",
dataType:"text",
beforeSend:function(){
$('html').css("cursor","wait");
},
complete:function(){
$('html').css("cursor","auto");
},
success:function(data){
var result = eval("("+data+")");
if(result.data[0].msg == null || result.data[0].msg == ''){
var url = "http://www.egov.go.kr/egovg4c/user/cs020/retrieveMinWonInfo.do?cappIsuSeq="+result.data[0].cappIsuSeq+"&random="+result.data[0].randomKey;
window.open(url,'minwonPop', 'resizable=no, WIDTH=570,HEIGHT=480');
}else{
alert(result.data[0].msg);
}
clickFlag = false;
},
error:function(jqXHR,textStatus,errorThrown){
alert("error")
//alert("error : "+textStatus+ "//" + jqXHR )
}
});
}
</script>
-----------------------------------------------------------------
ajax return:
<%@ page language="java" contentType="text/javascript; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
{
"data": [
{
"cappIsuSeq":"${cappIsuSeq}",
"randomKey":"${randomKey}",
"msg":"${msg}"
<c:if test="${!status.last}" >}, </c:if>
<c:if test="${status.last}" > } </c:if>
]
}
------------------------------------------------------------
<script type="text/javascript" language="javascript">
var clickFlag = false;
function minwonView(requestNo) {
var frm = document.searchForm;
frm.requestNo.value=requestNo;
var userType = '${userType}';
if(clickFlag ==true){
alert("wait");
return;
}
clickFlag =true;
var paramData = $("#searchForm").serialize();
var url = '/test/testMinwon.do';
$.ajax({
url: url,
data: paramData,
type:"POST",
dataType:"text",
beforeSend:function(){
$('html').css("cursor","wait");
},
complete:function(){
$('html').css("cursor","auto");
},
success:function(data){
var result = eval("("+data+")");
if(result.data[0].msg == null || result.data[0].msg == ''){
var url = "http://www.egov.go.kr/egovg4c/user/cs020/retrieveMinWonInfo.do?cappIsuSeq="+result.data[0].cappIsuSeq+"&random="+result.data[0].randomKey;
window.open(url,'minwonPop', 'resizable=no, WIDTH=570,HEIGHT=480');
}else{
alert(result.data[0].msg);
}
clickFlag = false;
},
error:function(jqXHR,textStatus,errorThrown){
alert("error")
//alert("error : "+textStatus+ "//" + jqXHR )
}
});
}
</script>
-----------------------------------------------------------------
ajax return:
<%@ page language="java" contentType="text/javascript; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
{
"data": [
{
"cappIsuSeq":"${cappIsuSeq}",
"randomKey":"${randomKey}",
"msg":"${msg}"
<c:if test="${!status.last}" >}, </c:if>
<c:if test="${status.last}" > } </c:if>
]
}