ajax调用后端函数
目录
ajax调用后端函数
<script>
function SendHttpRequest() {
$.ajax({
url: "/lay",// The URL for the request
// data: { },// The data to send (will be converted to a query string)
type: "GET",// Whether this is a POST or GET request
// dataType:'json'
success: function(res) {
// response = JSON.stringify(res);
showData(res);
}
})
}
function test(){
$("#target").html("");
var str="<tr><td>welcome</td></tr>";
$("#target").append(str);
}
function showData(response){
$("#target").html("");
var str="";
for(var i=0;i<response.length;i++){
str="<tr><td>" + response[i].id + "</td><td>" + response[i].nickname + "</td></tr>";
$("#target").append(str);
}
}
</script>