jQuery對Ajax的支援

Zery_發表於2020-11-26
$.ajax()
	<script type="text/javascript">
		alert("begin");
		$(function(){
			$.ajax({
				"url" : "/Ajax/ajax",
				"type" : "post",
				"data" : "op=end",
				"dataType" : "json",
				"success" : function(json){
					console.log(json);
				},
				"error" : function(xmlhttp, errorText){
					console.log(xmlhttp);
					console.log(errorText);
					if(xmlhttp.status == "405"){
						alert("無效的請求");
					} else if(xmlhttp.status == "404"){
						alert("找不到檔案");
					} else if(xmlhttp.status == "500"){
						alert("伺服器壞了");
					} else {
						alert("BAD");
					}
				}
			})
		})
		alert("finish");
	</script>

相關文章