Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Flash and Ajax to achieve non-refresh paging function

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "how to use Flash and Ajax to achieve no refresh paging function", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "how to use Flash and Ajax to achieve no refresh paging function" bar!

In practical application, XML files are generally generated by background scripts, and then the data generated by them are manipulated.

Due to the lack of space, 1.xml 2.xml 3.xml will be used instead in this article. The background script does not provide instructions.

First, understand the structure of a XML:

The code is as follows:

Happiness terminal

Desperate termination station

Horror movie

...

... .

Let's start with a simple Flash

The code is as follows:

Function setxml (page) {

PageXml = new XML (); / / declare the XML object

PageXml.ignoreWhite = true; / / allow blanks

PageXml.load (page+ ".xml? rid=" + Math.random ()); / / read the XML file

PageXml.onLoad = function (success)

{

If (success)

{

ParseXml (pageXml); / / if read successfully, analyze the XML file

}

}

}

Function parseXml (pageXml) {

Xmlroot = ageXml.firstChild; / / define the XML root directory

For (iTunes 0, investors 0)

{

Var strName= "Msxml2.XMLHTTP"

If (navigator.appVersion.indexOf ("MSIE 5.5") > = 0) / / even IE has two declaration methods

{

StrName= "Microsoft.XMLHTTP"

}

Try

{

ObjXmlHttp=new ActiveXObject (strName)

ObjXmlHttp.onreadystatechange=handler

Return objXmlHttp

}

Catch (e)

{

Alert ("Error. Scripting for ActiveX might be disabled")

Return

}

}

Else

{

ObjXmlHttp=new XMLHttpRequest (); / / Firefox, Opera and so on all use this

ObjXmlHttp.onload=handler

ObjXmlHttp.onerror=handler

Return objXmlHttp

}

}

/ / the function to be called first can be regarded as the setxml () function in Flash above

Function showpage (no)

{

Document.getElementById ("loadstatus") [xss_clean] = "Lading..."

Var url = no+ ".xml? rid=" + Math.random ()

/ / stateChanged_showplist is the following function name, be careful not to add parentheses

XmlHttp=GetXmlHttpObject (stateChanged_showplist)

/ / the transfer method is GET, or you can choose POST mode. Sometimes, if you pass variables in Chinese, remember to set the file header.

XmlHttp.open ("GET", url, true)

XmlHttp.send (null)

}

/ / analyze XML function

Function stateChanged_showplist ()

{

If (xmlHttp.readyState==4 | | xmlHttp.readyState== "complete") / / xmlHttp.readyState==4 4 indicates the end of reading

{

Document.getElementById ("loadstatus") [xss_clean] = ""

Table = document.getElementById ("pagebody"); / / generate TALBE Element

For (I = table.rows.length-1; I > = 0; I -) / / delete the existing rows, otherwise the table will extend infinitely

Table.deleteRow (I)

Xmlroot = xmlHttp.responseXML.getElementsByTagName ("movie"); / / get the root required by XML

For (iPre0There i1)

{

Prepage = page*1-1

Var changpage = "previous page"

}

Else

{

Changpage = "previous page"

}

If (page

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report