您的位置:首页 > 理论基础 > 计算机网络

JQuery http status 201处理

2016-10-23 09:01 148 查看
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script src="js/jquery.min.js"></script>
<script type="text/javascript">

function requestJson() {
$.ajax({
type : 'post',
url : 'http://localhost:8080/ajaxdemo/CreateUserServlet',
dataType : 'text',
//data : '{"id":"4","usercode":"44","password":"123"}',
statusCode: {
201: function() {
alert( "created" );
}

},
complete : function( jqXHR, textStatus ) {
alert("complete");
alert(jqXHR.status);    //alert 201
alert(jqXHR.responseText );
alert(textStatus);
}

});
}
</script>
</head>
<body>
<input type="button" onclick="requestJson()" value="reqeust" />
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐