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 write an encapsulated Ajax class

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article focuses on "how to write an encapsulated Ajax class", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to write an encapsulated Ajax class.

Usage:

New Ajax () Request (url,cmd,async,method,postString,title)

Parameters:

Url: request page URL (required)

Cmd: return value handler (required)

Async: whether asynchronous, (ture | false), default true

Method: request method, (post | get), default get

PostString: request content when the request method is post

Title: request content title

The code is as follows:

/ / Ajax package 2007-3-13

Function createXMLHttpRequest () {

Try {

If (window.XMLHTTPRequest) {

Return new XMLHttpRequest ()

}

Else if (window.ActiveXObject) {

Return new ActiveXObject ("Microsoft.XMLHTTP")

}

}

Catch (e) {alert ("XMLHttpRequest object cannot be created! please check IE security settings!") ;}

}

Function messageDiv (t)

{

Var v = document.createElement ("")

V [XSS _ clean] = "" +

"" +

"" +

"

"+ t +", the connection is not initialized. "

Var l = document.getElementsByName ("message") .length

V.style.cssText = "position:absolute;bottom:" + (lumb24) + "px;left:0px;display:none"

Document.body.appendChild (v)

This.clear = function () {

Document.body.removeChild (v)

Var msg = document.getElementsByName ("message")

For (var iTuno Bandi)

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