$.ajax( {
type : "POST",
url : "/home/user/login.htm", //訪問路徑
data : {name: name, title: title}, //參數
success : function(msg) {
if (msg == 1) {
} else {
}
},
error:function(msg){
alert("程序出錯,請聯系管理員");
}
});
java類方法:
@RequestMapping("user/login.htm")
public String getAddGroupsAjax(String name,String title) throws Exception{
HttpServletResponse response = getResponse();
response.setContentType("text/html;charset=UTF-8");
PrintWriter pw = null;
//方法處理,最後返回壹個字符竄,來判斷是成功還是失敗了
try {
pw = response.getWriter();
pw.print(str);
} catch (IOException e) {
//錯誤處理
}finally{
pw.close();
}
return null;
}
以上最少需要妳懂壹些springMVC,不然的話我也沒辦法