Ajax几个简单的案例(ajax_用户唯一验证、ajax_返回xml数据的处理(包括分页处理)

当然开发的前提是把相应的包导入项目中(开发环境myeclipse

ajax_用户唯一验证(servlet):

如图在myeclipse中的ajax_servlet项目中的index.jsp实现页面的显示:

Index.jsp代码:

<%@pagelanguage="java"import="java.util.*"pageEncoding="UTF-8"%>

<%

Stringpath=request.getcontextpath();

StringbasePath=request.getScheme()+"://"

+request.getServerName()+":"+request.getServerPort()

+path+"/";

%>

<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN">

<html>

<head>

<basehref="<%=basePath%>">

<title>MyJSP'index.jsp'startingpage</title>

<Metahttp-equiv="pragma"content="no-cache">

<Metahttp-equiv="cache-control"content="no-cache">

<Metahttp-equiv="expires"content="0">

<Metahttp-equiv="keywords"content="keyword1,keyword2,keyword3">

<Metahttp-equiv="description"content="Thisismypage">

<!--

<linkrel="stylesheet"type="text/css"href="styles.css">

-->

<scripttype="text/javascript"

src="${pageContext.request.contextpath}/js/util.js"></script>

<scripttype="text/javascript"

src="${pageContext.request.contextpath}/js/user/reg.js"></script>

</head>

<body>

<divalign="center">

<formaction="">

用户名:<inputtype="text"id="uname"/><spanid="cname"></span><br>

码:<inputtype="password"id="upass"/><br><input

type="submit"value="注册"/>

</form>

</div>

</body>

</html>

然后在webroot下新建一个js文件夹,这个里面写我们的js代码实现ajax使用

util.js中封装了发送和接收的请求和一些必要的代码

Util.js文件代码:

//通过id获取dom对象

function$(id){

returndocument.getElementById(id);

}

//创建XMLHttpRequest对象

functioncreateXHR(){

//声明

varxhr;

//IE浏览器XMLHTTP组件的名称

varaVertion=["MSXML2.XMLHttp.5.0","MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0","MSXML2.XMLHttp.2.0","Microsoft.XMLHttp"];

try{

//firefoxopera等浏览器

xhr=newXMLHttpRequest();

}catch(ex){

for(vari=0;i<aVertion.lengrh;i++){

try{

xmlHttpRequest=newActiveXObject(aVersion[i]);

returnxmlHttpRequest;

}catch(ex){

continue;

}

}

}

returnxhr;

}

varxhr=createXHR();

functionsendPost(content,url,success,fail){

//ajax处理操作

//创建xhr对象

//触发器

xhr.onreadystatechange=function(){

if(xhr.readyState==4){

if(xhr.status==200||xhr.status==304){

success(xhr);

}else{

fail(xhr);

}

}

};

//打开请求

xhr.open("POST",true);

//设置类型

xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

//发送请求

xhr.send(content);

}

然后再user下的reg.js中写要完成的代码

Reg.js文件代码:

window.onload=function(){

//获取id="uname"节点对象

varunameDom=$("uname");

//为节点注册onblur事件

unameDom.onblur=function(){

//根据value属性获取穿的的值并且拼成传递的参数

varcontent="name="+unameDom.value;

//封装请求的url路径

varurl="./servlet/regUser.do?time="+newDate().getTime();

sendPost(content,disposeSuccess,disposeFail);

functiondisposeSuccess(){

$("cname").innerHTML=xhr.responseText;

}

functiondisposeFail(){

alert("请求失败");

}

};

};

最后在src下建立action处理方法

UserAction.java文件代码:

packagewww.csdn.net.servlet;

importjava.io.IOException;

importjava.io.PrintWriter;

importjavax.servlet.servletexception;

importjavax.servlet.http.HttpServlet;

importjavax.servlet.http.HttpServletRequest;

importjavax.servlet.http.HttpServletResponse;

publicclassUserServletextendsHttpServlet{

/**

*

*/

privatestaticfinallongserialVersionUID=1L;

publicvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)

throwsservletexception,IOException{

this.doPost(request,response);

}

publicvoiddoPost(HttpServletRequestrequest,IOException{

Stringname=request.getParameter("name");

System.out.println("===="+name);

response.setContentType("text/html;charset=utf-8");

PrintWriterout=response.getWriter();

if("xiao".equals(name)){

out.print("用户已经存在");//输出文本

}else{

out.print("用户名可以使用");

}

out.flush();

out.close();

}

/**

*Initializationoftheservlet.<br>

*

*@throwsservletexceptionifanerroroccurs

*/

publicvoidinit()throwsservletexception{

//Putyourcodehere

}

}

这样就完成了,发布到tomcat服务器上然后用火狐浏览器测试就可以了

ajax_用户唯一验证(struts2)

如图所示;

首先实现页面的代码:

Index.jsp文件代码:

<%@pagelanguage="java"import="java.util.*"pageEncoding="UTF-8"%>

<%@tagliburi="/struts-tags"prefix="s"%>

<%

Stringpath=request.getcontextpath();

StringbasePath=request.getScheme()+"://"

+request.getServerName()+":"+request.getServerPort()

+path+"/";

%>

<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN">

<html>

<head>

<basehref="<%=basePath%>">

<title>MyJSP'index.jsp'startingpage</title>

<Metahttp-equiv="pragma"content="no-cache">

<Metahttp-equiv="cache-control"content="no-cache">

<Metahttp-equiv="expires"content="0">

<Metahttp-equiv="keywords"content="keyword1,keyword3">

<Metahttp-equiv="description"content="Thisismypage">

<!--

<linkrel="stylesheet"type="text/css"href="styles.css">

-->

<scripttype="text/javascript"

src="${pageContext.request.contextpath}/js/util.js"></script>

<scripttype="text/javascript"

src="${pageContext.request.contextpath}/js/user/reg.js"></script>

</head>

<body>

<divalign="center">

<h3>注册页面</h3>

</div>

<divalign="center">

<s:formaction="regUser"namespace="/csdn"theme="simple">

用户名:<s:textfieldname="usernaem"id="uname"/>

<spanid="cname"></span>

<br>

码:<s:textfieldname="userpass"id="upass"/>

<br>

箱:<s:textfieldname="useremial"id="uemail"/>

<br>

<s:submitvalue="注册"/>

</s:form>

</div>

</body>

</html>

Sc.jsp文件代码:

<%@pagelanguage="java"import="java.util.*"pageEncoding="UTF-8"%>

<%@tagliburi="/struts-tags"prefix="s"%>

<%

Stringpath=request.getcontextpath();

StringbasePath=request.getScheme()+"://"

+request.getServerName()+":"+request.getServerPort()

+path+"/";

%>

<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN">

<html>

<head>

<basehref="<%=basePath%>">

<title>MyJSP'index.jsp'startingpage</title>

<Metahttp-equiv="pragma"content="no-cache">

<Metahttp-equiv="cache-control"content="no-cache">

<Metahttp-equiv="expires"content="0">

<Metahttp-equiv="keywords"content="keyword1,keyword3">

<Metahttp-equiv="description"content="Thisismypage">

<!--

<linkrel="stylesheet"type="text/css"href="styles.css">

-->

<scripttype="text/javascript"

src="${pageContext.request.contextpath}/js/util.js"></script>

<scripttype="text/javascript"

src="${pageContext.request.contextpath}/js/user/reg.js"></script>

</head>

<body>

。。。。。。。。。

</body>

</html>

然后是js文件

Util.js文件代码:

//通过id获取dom对象

function$(id){

returndocument.getElementById(id);

}

//创建XMLHttpRequest对象

functioncreateXHR(){

//声明

varxhr;

//IE浏览器XMLHTTP组件的名称

varaVertion=["MSXML2.XMLHttp.5.0","Microsoft.XMLHttp"];

try{

//firefoxopera等浏览器

xhr=newXMLHttpRequest();

}catch(ex){

for(vari=0;i<aVertion.lengrh;i++){

try{

xmlHttpRequest=newActiveXObject(aVersion[i]);

returnxmlHttpRequest;

}catch(ex){

continue;

}

}

}

returnxhr;

}

Reg.js文件代码:

window.onload=function(){

//获取id="uname"节点对象

varunameDom=$("uname");

//为节点注册onblur事件

unameDom.onblur=function(){

//根据value属性获取穿的的值并且拼成传递的参数

varcontent="name="+unameDom.value;

//封装请求的url路径

varurl="./csdn/UserAction_checkName.action?time="+newDate().getTime();

//获取创建的xhr对象(XMLHTTPRequest对象)

varxhr=createXHR();

//事件处理函数触发器

xhr.onreadystatechange=function(){

if(xhr.readyState==4){//状态码返回4处理完毕(这样才能使用xhr.responseText获取返回的结果)

if(xhr.status==200||xhr.status==304){//服务器返回的状态码200一切ok304服务器没有被修改

//ajax请求之后再这里做相应的处理

$("cname").innerHTML=xhr.responseText;

//如果接收的是XML文件就用responseXML;

}

}

};

//打开请求

xhr.open("POST",true);

//如果用POST请求向服务器发送数据,需要将“Content-type”的首部

//设置为“application/x-www-form-urlencoded它会告知服务器正在发送数据,并且数据已经符合URL编码了

xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");

//发送请求

xhr.send(content);

};

};

Struts.xml文件代码:

<?xmlversion="1.0"encoding="UTF-8"?>

<!DOCTYPEstrutsPUBLIC

"-//ApacheSoftwareFoundation//DTDStrutsConfiguration2.3//EN"

"http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>

<includefile="www/csdn/project/resource/struts-constant.xml"/>

<packagename="test"namespace="/csdn"extends="struts-default">

<actionname="UserAction_*"class="www.csdn.project.action.UserAction"method="{1}">

<resultname="reg"type="plainText">

<paramname="location">/sc.jsp</param>

<paramname="charSet">UTF-8</param>

</result>

</action>

</package>

</struts>

最后UserAction.java文件代码:

packagewww.csdn.project.action;

importjava.io.IOException;

importjava.io.PrintWriter;

importjavax.servlet.http.HttpServletResponse;

importorg.apache.struts2.ServletActionContext;

importcom.opensymphony.xwork2.ActionSupport;

publicclassUserActionextendsActionSupport{

/**

*

*/

privatestaticfinallongserialVersionUID=1L;

privateStringname;

publicStringgetName(){

returnname;

}

publicvoidsetName(Stringname){

this.name=name;

}

publicStringcheckName(){

HttpServletResponseresponse=ServletActionContext.getResponse();//获取response对象

response.setContentType("text/html;charset=utf-8");//设置相应文档类型

PrintWriterout=null;//声明输出的out对象

try{

out=response.getWriter();//根据response对象获取out对象

}catch(IOExceptione){

e.printstacktrace();

}

if("xiao".equals(name)){

out.print("用户已经存在");//输出文本

}else{

out.print("用户名可以使用");

}

out.flush();//立即写入

out.close();//关闭

return"reg";

}

}

ajax_返回xml数据的处理(包括分页)(数据库自己建立,在DAO层和service层实现用hibernate

如图项目结构

连接数据库

数据库在相应层实现就行

首先实现页面的显示

Index.jsp文件代码:

<%@pagelanguage="java"import="java.util.*"pageEncoding="UTF-8"%>

<%@tagliburi="/struts-tags"prefix="s"%>

<%

Stringpath=request.getcontextpath();

StringbasePath=request.getScheme()+"://"

+request.getServerName()+":"+request.getServerPort()

+path+"/";

%>

<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN">

<html>

<head>

<basehref="<%=basePath%>">

<title>MyJSP'index.jsp'startingpage</title>

<Metahttp-equiv="pragma"content="no-cache">

<Metahttp-equiv="cache-control"content="no-cache">

<Metahttp-equiv="expires"content="0">

<Metahttp-equiv="keywords"content="keyword1,keyword3">

<Metahttp-equiv="description"content="Thisismypage">

<!--

<linkrel="stylesheet"type="text/css"href="styles.css">

-->

</head>

<body>

<divalign="center">

<ahref="${pageContext.request.contextpath}/csdn/UserAction_login.action">进入后台</a>

</div>

</body>

</html>

Cindex.jsp文件代码:

<%@pagelanguage="java"import="java.util.*"pageEncoding="UTF-8"%>

<%@tagliburi="/struts-tags"prefix="s"%>

<%

Stringpath=request.getcontextpath();

StringbasePath=request.getScheme()+"://"

+request.getServerName()+":"+request.getServerPort()

+path+"/";

%>

<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN">

<html>

<head>

<basehref="<%=basePath%>">

<title>MyJSP'index.jsp'startingpage</title>

<Metahttp-equiv="pragma"content="no-cache">

<Metahttp-equiv="cache-control"content="no-cache">

<Metahttp-equiv="expires"content="0">

<Metahttp-equiv="keywords"content="keyword1,keyword3">

<Metahttp-equiv="description"content="Thisismypage">

<!--

<linkrel="stylesheet"type="text/css"href="styles.css">

-->

<scripttype="text/javascript"src="${pageContext.request.contextpath}/js/util.js"></script>

<scripttype="text/javascript"src="${pageContext.request.contextpath}/js/user/user_checkName.js"></script>

<scripttype="text/javascript"src="${pageContext.request.contextpath}/js/user/user_query.js"></script>

</head>

<body>

<divalign="center">

<divstyle="border:1px;width:600px;height:400px;">

<tablewidth="300px">

<tr>

<td>

用户名:

</td>

<td>

<s:textfieldid="uname"name="username"theme="simple"></s:textfield>

</td>

<tdstyle="color:red;font-size:10px;"id="cname">

</td>

</tr>

<tr>

<td>

:

</td>

<td>

<s:passwordid="upass"name="userpass"theme="simple"></s:password>

</td>

<td>

</td>

</tr>

<tr>

<tdcolspan="3"style="text-align:center;">

<s:ahref="#"theme="simple">注册</s:a>

</td>

</tr>

</table>

</div>

<div>

<span>不使用它</span>

<s:urlid="user_query"namespace="/csdn"action="UserAction_query"></s:url>

<s:ahref="%{user_query}">查询所有用户</s:a>

</div>

<br/>

<div>

<inputtype="button"value="查询所有用户"id="queryBtn">

</div>

<div>

<h3>显示所有的用户信息</h3>

<tableborder="1px"cellpadding="0"cellspacing="0">

<thead>

<th><inputtype="checkBox"id="qx"/></th>

<th>序号</th>

<th>姓名</th>

<th>性别</th>

<th>职位</th>

<th>操作</th>

</thead>

<tbodyid="showUsers"></tbody>

</table>

</div>

</div>

</body>

</html>

userpage_xml.js文件:(这里实现了分页)

window.onload=function(){

varuserBtnDom=$("userBtn");

userBtnDom.onclick=function(){

//封装请求的数据

varcontent="pagination.NowPage="+1;

//封装请求的路径

varurl="./csdn/UserAction_pagexml.action?time="

+newDate().getTime();

//调用封装的ajaxpost请求

sendPost(content,disposeFail);

//成功处理函数

functiondisposeSuccess(xhr){

//接受相应的xml数据并且返回xmlDocument对象

varxmlDoc=xhr.responseXML;

//获取根对象

varroot=xmlDoc.documentElement;

//获取根节点中所有的Member节点对象

varusers=root.getElementsByTagName("user");

//显示数据

showUsers(users);

$("firstPage").onclick=function(){

content="pagination.NowPage="+1;

//发送请求的时候

sendPost(content,disposeFail);

};

$("backPage").onclick=function(){

content="pagination.NowPage="+eval(root.getAttribute("Nowpage")+"-"+1);

//发送请求的时候

sendPost(content,disposeFail);

};

$("nextPage").onclick=function(){

content="pagination.NowPage="+eval(root.getAttribute("Nowpage")+"+"+1);

//发送请求的时候

sendPost(content,disposeFail);

};

$("lastPage").onclick=function(){

content="pagination.NowPage="+root.getAttribute("countPage");

//发送请求的时候

sendPost(content,disposeFail);

};

}

//失败处理函数

functiondisposeFail(xhr){

alert("失败处理");

}

};

};

varupTr=null;

functionshowUsers(users){

//清空操作

if($("showUsers").hasChildNodes()){

for(varjj=0;jj<$("showUsers").childNodes.length;){

$("showUsers").removeChild($("showUsers").childNodes[jj]);

}

}

for(vari=0;i<users.length;i++){

varuser=users[i];

vartr=document.createElement("tr");

vartd1=document.createElement("td");

varinput=document.createElement("input");

input.setAttribute("type","checkBox");

input.setAttribute("value",user.getAttribute("id"));

td1.appendChild(input);

vartd2=document.createElement("td");

td2.appendChild(document.createTextNode(user.getAttribute("id")));

vartd3=document.createElement("td");

td3.appendChild(document.createTextNode(user

.getElementsByTagName("name")[0].firstChild.nodeValue));

vartd4=document.createElement("td");

td4.appendChild(document.createTextNode(user

.getElementsByTagName("sex")[0].firstChild.nodeValue));

vartd5=document.createElement("td");

td5.appendChild(document.createTextNode(user

.getElementsByTagName("role")[0].firstChild.nodeValue));

vartd6=document.createElement("td");

//创建修改按钮

varupdateBtn=document.createElement("button");

//为按钮添加文本节点

updateBtn.appendChild(document.createTextNode("编辑"));

updateBtn.onclick=function(){

upTr=this.parentNode.parentNode;

vartds=upTr.childNodes;

for(vari=0;i<tds.length;i++){

vartd=tds[i];

if(td.nodeType==1){

if(i==0){

domUserName.value=td.firstChild.nodeValue;

}elseif(i==1){

domUserSex.value=td.lastChild.nodeValue;

}elseif(i==2){

domUserRole.value=td.childNodes[0].nodeValue;

}

}

};

};

td6.appendChild(updateBtn);

tr.appendChild(td1);

tr.appendChild(td2);

tr.appendChild(td3);

tr.appendChild(td4);

tr.appendChild(td5);

tr.appendChild(td6);

$("showUsers").appendChild(tr);

}

}

functionsendPost(content,fail){

//ajax处理操作

//创建xhr对象

varxhr=createXHR();

//触发器

xhr.onreadystatechange=function(){

if(xhr.readyState==4){

if(xhr.status==200||xhr.status==304){

success(xhr);

}else{

fail(xhr);

}

}

};

//打开请求

xhr.open("POST","application/x-www-form-urlencoded");

//发送请求

xhr.send(content);

}

Struts.xml文件代码:

<?xmlversion="1.0"encoding="UTF-8"?>

<!DOCTYPEstrutsPUBLIC

"-//ApacheSoftwareFoundation//DTDStrutsConfiguration2.3//EN"

"http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>

<includefile="www/csdn/project/resource/struts-constant.xml"/>

<packagename="test"namespace="/csdn"extends="struts-default">

<actionname="UserAction_*"class="www.csdn.project.action.UserAction"method="{1}">

<resultname="login">/WEB-INF/page/user/user_list.jsp</result>

<resultname="xml"type="plainText">

<paramname="location">./index.jsp</param>

<paramname="charSet">UTF-8</param>

</result>

</action>

</package>

</struts>

分页的实现是在util层中封装的实现分页的代码:

Pagination.java文件代码:

packagewww.csdn.project.util;

importjava.util.ArrayList;

importjava.util.List;

/**

*

*@authorkun

*

*

*@param<T>

*/

publicclasspagination<T>extendsBaseHibernateDAO{

//每页显示的记录数

privatestaticfinalIntegerPAGESIZE=5;

//总页数

privateIntegercountPage;

//当前页

privateIntegerNowPage;

//总记录数

privateIntegercountRecond;

//当前页数据

privateList<T>entities;

/**

*默认构造器

*/

publicPagination(){

super();

}

/**

*带有参数的构造器

*

*@paramclassName

*@paramNowPage

*/

publicPagination(Class<T>className,intNowPage){

this.countRecond=getCountRecord(className);

this.countPage=this.countRecond%PAGESIZE==0?this.countRecond

/PAGESIZE:this.countRecond/PAGESIZE+1;

//关于当前的处理

if(NowPage<=1){

this.NowPage=1;

}else{

if(NowPage>=this.countPage){

this.NowPage=this.countPage;

}else{

this.NowPage=NowPage;

}

}

this.entities=getNowPageInfo(this.NowPage,className);

}

publicIntegergetCountPage(){

returncountPage;

}

publicvoidsetCountPage(IntegercountPage){

this.countPage=countPage;

}

publicIntegergetNowPage(){

returnNowPage;

}

publicvoidsetNowPage(IntegerNowPage){

this.NowPage=NowPage;

}

publicIntegergetCountRecond(){

returncountRecond;

}

publicvoidsetCountRecond(IntegercountRecond){

this.countRecond=countRecond;

}

publicList<T>getEntities(){

returnentities;

}

publicvoidsetEntities(List<T>entities){

this.entities=entities;

}

/**

*等到总记录数

*

*@paramclassName

*@return

*/

publicIntegergetCountRecord(Class<T>className){

inti=0;

try{

i=Integer.parseInt(this.getSession().createquery(

"selectcount(c)from"+className.getName()+"c")

.uniqueResult().toString());

}catch(Exceptione){

e.printstacktrace();

}finally{

HiberSessionFactory.closeSession();

}

returni;

}

/**

*获取当前页的信息

*

*@paramNowpage

*@paramclassName

*@return

*/

@SuppressWarnings("unchecked")

publicList<T>getNowPageInfo(IntegerNowpage,Class<T>className){

List<T>entities=newArrayList<T>();

try{

entities=this.getSession().createCriteria(className)

.setFirstResult((Nowpage-1)*PAGESIZE).setMaxResults(

PAGESIZE).list();

}catch(Exceptione){

e.printstacktrace();

}finally{

HiberSessionFactory.closeSession();

}

returnentities;

}

}

最后在UserAction.java文件中实现XML数据处理:

UserAction.java文件代码:

packagewww.csdn.project.action;

importjava.io.IOException;

importjava.io.PrintWriter;

importjavax.servlet.http.HttpServletResponse;

importorg.apache.struts2.ServletActionContext;

importwww.csdn.project.domain.User;

importwww.csdn.project.util.Pagination;

importcom.opensymphony.xwork2.ActionSupport;

publicclassUserActionextendsActionSupport{

/**

*

*/

privatestaticfinallongserialVersionUID=1L;

privatePagination<User>pagination;

publicvoidsetPagination(Pagination<User>pagination){

this.pagination=pagination;

}

publicStringpagexml(){

//当前页信息

pagination=newPagination<User>(User.class,pagination.getNowPage());

HttpServletResponseresponse=ServletActionContext.getResponse();

response.setContentType("text/xml;charset=utf-8");

PrintWriterout=null;

try{

out=response.getWriter();

out.println("<?xmlversion='1.0'encoding='UTF-8'?>");

out.print("<usersNowpage='"+pagination.getNowPage()+"'countPage='"+pagination.getCountPage()+"'countRecond='"+pagination.getCountRecond()+"'>");

for(Userentity:pagination.getEntities()){

out.print("<userid='"+entity.getId()+"'>");

out.print("<name>");

out.print(entity.getName());

out.print("</name>");

out.print("<sex>");

out.print(entity.getSex());

out.print("</sex>");

out.print("<role>");

out.print(entity.getRole());

out.print("</role>");

out.print("</user>");

}

out.print("</users>");

out.flush();

out.close();

}catch(IOExceptione){

e.printstacktrace();

}

return"xml";

}

publicStringlogin(){

return"login";

}

}

Ajax几个简单的案例ajax_用户唯一验证、ajax_返回xml数据的处理包括分页处理的更多相关文章

  1. HTML实现代码雨源码及效果示例

    这篇文章主要介绍了HTML实现代码雨源码及效果示例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

  2. html5 拖拽及用 js 实现拖拽功能的示例代码

    这篇文章主要介绍了html5 拖拽及用 js 实现拖拽,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

  3. HTML文本属性&amp;颜色控制属性的实现

    这篇文章主要介绍了HTML文本属性&颜色控制属性的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

  4. 简洁自适应404页面HTML好看的404源码

    这篇文章主要介绍了简洁自适应404页面HTML好看的404源码,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

  5. amaze ui 的使用详细教程

    这篇文章主要介绍了amaze ui 的使用详细教程,本文通过多种方法给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

  6. HTML5适合的情人节礼物有纪念日期功能

    这篇文章主要介绍了HTML5适合的情人节礼物有纪念日期功能,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

  7. 如何给HTML标签中的文本设置修饰线

    这篇文章主要介绍了如何给HTML标签中的文本设置修饰线,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

  8. HTML5调用手机发短信和打电话功能

    这篇文章主要介绍了HTML5调用手机发短信和打电话功能,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

  9. HTML利用九宫格原理进行网页布局

    这篇文章主要介绍了HTML利用九宫格原理进行网页布局,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

  10. HTML中实现音乐或视频自动播放案例详解

    由于期末大作业我想插入一个背景音乐,实现点开网页就会自动播放音频的效果,今天通过本文给大家分享下我基于HTML实现音乐或视频自动播放功能,代码简单易懂,需要的朋友参考下吧

随机推荐

  1. xe-ajax-mock 前端虚拟服务

    最新版本见Github,点击查看历史版本基于XEAjax扩展的Mock虚拟服务插件;对于前后端分离的开发模式,ajax+mock使前端不再依赖后端接口开发效率更高。CDN使用script方式安装,XEAjaxMock会定义为全局变量生产环境请使用xe-ajax-mock.min.js,更小的压缩版本,可以带来更快的速度体验。

  2. vue 使用 xe-ajax

    安装完成后自动挂载在vue实例this.$ajaxCDN安装使用script方式安装,VXEAjax会定义为全局变量生产环境请使用vxe-ajax.min.js,更小的压缩版本,可以带来更快的速度体验。cdnjs获取最新版本点击浏览已发布的所有npm包源码unpkg获取最新版本点击浏览已发布的所有npm包源码AMD安装require.js安装示例ES6Module安装通过Vue.use()来全局安装示例./Home.vue

  3. AJAX POST数据中文乱码解决

    前端使用encodeURI进行编码后台java.net.URLDecoder进行解码编解码工具

  4. Koa2框架利用CORS完成跨域ajax请求

    实现跨域ajax请求的方式有很多,其中一个是利用CORS,而这个方法关键是在服务器端进行配置。本文仅对能够完成正常跨域ajax响应的,最基本的配置进行说明。这样OPTIONS请求就能够通过了。至此为止,相当于仅仅完成了预检,还没发送真正的请求呢。

  5. form提交时,ajax上传文件并更新到&lt;input&gt;中的value字段

  6. ajax的cache作用

    filePath="+escape;},error:{alert;}});解决方案:1.加cache:false2.url加随机数正常代码:网上高人解读:cache的作用就是第一次请求完毕之后,如果再次去请求,可以直接从缓存里面读取而不是再到服务器端读取。

  7. 浅谈ajax上传文件属性contentType = false

    默认值为contentType="application/x-www-form-urlencoded".在默认情况下,内容编码类型满足大多数情况。在这里,我们主要谈谈contentType=false.在使用ajax上传文件时:在其中先封装了一个formData对象,然后使用post方法将文件传给服务器。说到这,我们发现在JQueryajax()方法中我们使contentType=false,这不是冲突了吗?这就是因为当我们在form标签中设置了enctype=“multipart/form-data”,

  8. 909422229_ajaxFileUpload上传文件

    ajaxFileUpload.js很多同名的,因为做出来一个很容易。我上github搜AjaxFileUpload出来很多类似js。ajaxFileUpload是一个异步上传文件的jQuery插件传一个不知道什么版本的上来,以后不用到处找了。语法:$.ajaxFileUploadoptions参数说明:1、url上传处理程序地址。2,fileElementId需要上传的文件域的ID,即的ID。3,secureuri是否启用安全提交,默认为false。4,dataType服务器返回的数据类型。6,error

  9. AJAX-Cache:一款好用的Ajax缓存插件

    原文链接AJAX-Cache是什么Ajax是前端开发必不可少的数据获取手段,在频繁的异步请求业务中,我们往往需要利用“缓存”提升界面响应速度,减少网络资源占用。AJAX-Cache是一款jQuery缓存插件,可以为$.ajax()方法扩展缓存功能。

  10. jsf – Ajax update/render在已渲染属性的组件上不起作用

    我试图ajax更新一个有条件渲染的组件。我可以确保#{user}实际上是可用的。这是怎么引起的,我该如何解决呢?必须始终在ajax可以重新呈现之前呈现组件。Ajax正在使用JavaScriptdocument.getElementById()来查找需要更新的组件。但是如果JSF没有将组件放在第一位,那么JavaScript找不到要更新的内容。解决方案是简单地引用总是渲染的父组件。

返回
顶部