get和post之间的区别

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
*{ padding: 0; margin: 0;box-sizing: border-box;}
html,body{ min- 1200px;}
.province{ 200px; height: 50px; text-align: center; font-size: 20px;}
.city{ 200px; height: 50px; text-align: center; font-size: 20px;}
.code{ 200px; height: 50px; text-align: center; font-size: 20px;}
</style>
</head>
<body>
<div>
<select class="province">
<option>---选择省---</option>
</select>
<select class="city">
<option>选择市</option>
</select>
<select class="code">
<option>地区编码</option>
</select>
</div>
<script src="js/jquery-3.3.1.min.js"></script>
<script type="text/javascript">
$.get("city.json",function(data,status){
if(status){
console.log(data.城市代码);
$.each(data.城市代码, function(i,el) {
console.log(el);
var str="<option>"+el.省+"</option>";
$(".province").append(str);
});
}
$(".province").change(function(){
$(".city").html("<option>选择市</option>");
$(".code").html("<option>地区编码</option>");
$(data.城市代码).each(function(i,el){
if($(".province").val()==el.省){
console.log(el.市);
$(el.市).each(function(index,ele){
console.log(ele.市名);
var sta = "<option>"+ele.市名+"</option>";
$(".city").append(sta);
});
}
});
});
$(".city").change(function(){
$(".code").empty();
$(data.城市代码).each(function(i,el){

$(el.市).each(function(index,ele){
// console.log(ele);
if (ele.市名 == $(".city").val()) {
var str="<option>"+ele.编码+"</option>";
$(".code").append(str);
}
})
})
});
});
</script>
</body>
</html>

样式   /      内容/    引入/     应用get来获取/查询数据

应用get比较快捷它多用于查询或获取数据一般通过地址(URL)来查询或获取数据{get的url最大传值为256b}。然而post相比较安全它通常是来改变数据和添加数据通过内部数据的转换来实现它去提交{post是2M}。

写的时候尽量放在body里面去写,因为这样它不需要$(document).ready(funotion)

data(数据)

status(状态码)

$(".city").html("<option>选择市</option>");
$(".code").html("<option>地区编码</option>");(清空)

原文地址:https://www.cnblogs.com/d-z-j-boke/p/9708950.html