<script>
$(function(){
$.ajax({
type:"Get",
url:"http://localhost:8080/user/a",
// data:data,
dataType:"json",
success:function(data) {
for (var i = 0; i < data.length; i++) {
//console.log(data[i])
var c = data[i];
console.log(c)
str = "<tr><td>" + data[i].id + "</td><td>" + data[i].name + "</td><td>" + data[i].age + "</td></tr>";
//追加到table中
$("#favouredpolicy").append(str);
}
},
error : function() {
alert("服务器正忙,请稍后!")
}
})
//第二种get方法
var url = "http://localhost:8080/user/sd";
$.get(url,function(data) {
for(var index in data){
console.log(index)
var id = data[index].id
var username = data[index].username
var password = data[index].password
var phone = data[index].phone
var email = data[index].email
var status = data[index].status
var created = data[index].created
var ss = "<tr align='center'><td>"+id+"</td><td>"+username
+"</td><td>"+password+"</td><td>"+phone+"</td><td>"+email
+"</td><td>"+status+"</td><td>"+created+"</td></tr>"
$('#sss').append(ss)
}
})
})
</script>
前端ajax提交
最新推荐文章于 2022-10-30 20:00:00 发布