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";
}
}
}
});
});

 

posted on 2016-10-11 18:35  Red_Black  阅读(85)  评论(0)    收藏  举报

导航