jQuery ajax简单用法
2021-05-30 20:03
标签:back code else http submit href serial color jquery httpresponse(json.dumps(ret)) $(‘#form‘).serialize(),#表单中的值全部发到后台 getlist jQuery ajax简单用法 标签:back code else http submit href serial color jquery 原文地址:https://www.cnblogs.com/anhao-world/p/14635341.htmla id="ajax_submit">悄悄提交a>
script>
$(‘#ajax_submit‘).click(function () {
$.ajax({
url:"/host/",
type:‘POST‘,
data:{‘k1‘:123,‘k2‘:‘root‘},
success:function (data) {
alert(data)
if(data ==‘OK‘){
location.reload()
}else{
alert(data)
}
}
})
})
script>
a id="ajax_submit">悄悄提交a>
parse()#前端转换成json
traditional:true#发送列表不处理Ajax:
$.ajax({
url: ‘/index/‘,
data: {‘k‘: ‘v‘, ‘list‘: [1,2,3,4], ‘k3‘: JSON.stringfy({‘k1‘: ‘v‘}))}, $(form对象).serilize()
type: ‘POST‘,
dataType: ‘JSON‘:
traditional: true,
success:function(d){
location.reload() # 刷新
location.href = "http://www.soscw.com/某个地址" # 跳转
}
})