Path is to get system paths
var View_name=document.getelementbyid ("View_name");
var req=new xmlhttprequest ();
if (req) {
Req.onreadystatechange=function () {
if (req.readystate==4 && req.status==200) {//Judgment status, 4 is sent, 200 completed
if (req.responsetext==0) {
View_name.style.color= ' green ';
View_name.innerhtml= ' The user name can be used normally ';
}else if (req.responsetext==1) {
View_name.style.color= ' Red ';
View_name.innerhtml= ' The user name has already been used ';
}else{
View_name.style.color= ' Red ';
View_name.innerhtml= ' The username contains illegal characters! ’;
}
}
}
Req.open (' POST ', path+ '/ajax.do ');//struts
Req.open (' POST ', path+ '/ajax.servlet ');//servlet
Req.open (' POST ', path+ '/ajax.action ');//webwork
Req.setrequestheader (' Content-type ', ' application/x-www-form-urlencoded ');
Req.send ("")//Send parameter If there is a parameter req.send ("Username=" +user_name);
}
}
</script>
This JSP page does not get user name, is demo. There are <div> can change span, specific role to ask Art bar.
public class Ajaxaction extends Action {
Public Actionforward Execute (actionmapping mapping,
Actionform form,
HttpServletRequest request,
HttpServletResponse response)
Throws Exception {
PrintWriter out = Response.getwriter ();
Out.print (1);//ajax get all the output of the character. If the volume of data is large, you can also use XML to send and accept
return null;
}
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.