ajax请求

//页面
var data = {}; data['参数'] = 值; ... $.ajax({ type: "post", //请求方式get,post data: data, //需要传给后台的json数据 async:true, //true(异步)或 false(同步) dataType:"json", //string、json、text、script、jsonp、xml、html url: "", //方法路径 success: function (res) { if (res.status == 0) { //状态成功执行 //循环插入数据 $("#hostS").html(""); var html = ""; $.each(res.host,function (k,v) { html += ""; }); $("#hostS").append(html); } if (res.status == 1) { //状态失败执行 } } })

你可能感兴趣的:(ajax请求)