Home  >  Article  >  Web Front-end  >  jquery.post usage example code_jquery

jquery.post usage example code_jquery

WBOY
WBOYOriginal
2016-05-16 17:05:351171browse

Use ajax to verify whether an operation is performed on the front end.
jquery.post parameters are
url, [data], [callback], [type]

url: sending request address.

data: Key/value parameters to be sent.

callback: callback function when sending successfully.

type: Return content format, xml, html, script, json, text, _default.

Copy code The code is as follows:

$.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("You have already voted!");
}
}) ;

The action configuration in struts.xml is:
Copy code The code is as follows:

class="org.bkgd.ehome.jeeplugin.userapp.web.action.ActionHhArticleQuery">



Action
Copy code The code is as follows:

private String isVote;
public String getIsVote() {
return isVote;
}
public void setIsVote(String isVote) {
this.isVote = isVote;
}
public String checkVote(){
try {
List> 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:
The return value of the action method must be a global variable, and must have get and set methods. Local variables are not allowed.
The method has a return value and cannot be void.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn