ajax技術的目的是讓javascript發送http請求,與後臺通信,獲取數據和信息。ajax技術的原理是實例化xmlhttp對象,使用此對象與後臺通信。ajax通信的過程不會影響後續javascript的執行,從而實現異步。
下面例子.
分頁ajax 應用
function fenye(cpage) {
location = "<%=path%>/list?cpage="+cpage;
}
function qx(){
$(".ch").each(function() {
$(this).attr("checked",true);//false
})
}
function fx(){
$(".ch").each(function() {
$(this).attr("checked",!$(this).attr("checked"),true);
})
}
function plsc(){
var ids = "";
$(".ch:checked").each(function() {
ids+=","+$(this).val();
})
ids = ids.substring(1);
location="plsc?ids="+ids;
}
@RequestMapping("/plsc")
public String plsc(String ids) {
System.out.println(ids);
String[] split = ids.split(",");
for (String string : split) {
zm.deleteByPrimaryKey(Integer.valueOf(string));
}
return "redirect:lista";
}