Get the App
SLTechnology News&Howtos  ›  Development  › 

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

Shulou Source: shulou.com Published: 2022-06-03 19:40:24 10月05日 Update

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

Tags: Function content generation function file method learning code background object article script table previous analysis good scary happy next lieutenant general Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Shulou Technology macOS vpn MySQL