jquery+ajax小结
1、ajax请求:
<script type="text/javascript">
$(document).ready(function(){
$.ajax({
type:"POST",
url:getUrl()+"xxx.do",
dataType:"JSON",
xhrFields: {
withCredentials: true
},
success:mineUser
});
});
function mineUser(data){}
</script>
或者:
$('#openAnswer').click(function(){
$.ajax({
type:"POST",
url:getUrl()+"xxx.do",
dataType:"JSON",
xhrFields: {
withCredentials: true
},
success:function(data){
if(data.userInfo.state==3){
window.location.href="mine-mine.html";
}
else if(data.userInfo.state==2){
window.location.href="mine-applying-nopass.html";
}
else if(data.userInfo.state==1){
window.location.href="mine-applying.html";
}
else{
if(confirm("您的xxx现在未开通,现在去开通?")){
window.location="xxx.html";
}
}
}
});
});
浙公网安备 33010602011771号