欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jquery.post用法示例代碼

 更新時(shí)間:2014年01月03日 16:17:50   作者:  
使用ajax在前端驗(yàn)證是否執(zhí)行某個(gè)操作,下面為大家介紹下jquery.post的具體使用
使用ajax在前端驗(yàn)證是否執(zhí)行某個(gè)操作
jquery.post參數(shù)為
url,[data],[callback],[type]

url:發(fā)送請求地址。

data:待發(fā)送 Key/value 參數(shù)。

callback:發(fā)送成功時(shí)回調(diào)函數(shù)。

type:返回內(nèi)容格式,xml, html, script, json, text, _default。
復(fù)制代碼 代碼如下:

$.post('admin/HhCheckVote.do?ids=' + '${ids}', {}, function(flag) {
if(flag.isVote=="true"){
document.getElementById("jvForm").action="admin/HhArticleVoteCommit.do";
document.getElementById("jvForm").submit();
}else{
alert("您已經(jīng)投過票!");
}
});

struts.xml中action配置為:
復(fù)制代碼 代碼如下:

<action name="HhCheckVote" method="checkVote"
class="org.bkgd.ehome.jeeplugin.userapp.web.action.ActionHhArticleQuery">
<result type="json"></result>
</action>

Action
復(fù)制代碼 代碼如下:

private String isVote;
public String getIsVote() {
return isVote;
}
public void setIsVote(String isVote) {
this.isVote = isVote;
}
public String checkVote(){
try {
List<Map<String,Object>> list = aloneIMP.checkVote(ids,getCurrentUser()).search().getResultList();
if(list.size()==0){
isVote = "true";
}else{
isVote = "false";
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return SUCCESS;
}

PS:
action 方法的返回值需是全局變量,且必須有g(shù)et,set方法,局部變量則不行
方法有返回值,不能是void

相關(guān)文章

最新評論