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 establish Ajax+PHP quickly

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 establish Ajax+PHP quickly". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to build Ajax+PHP quickly".

Brief introduction:

Ajax consists of HTML, JavaScript ™technology, DHTML, and DOM, an excellent way to transform a clumsy Web interface into an interactive Ajax application.

For Ajax, the core object is XMLHttpRequest, and all Ajax operations are inseparable from the operation on this object.

Create a XMLHttpRequest object

For IE browsers:

The copy code is as follows:

XmlHttp = new ActiveXObject ('Microsoft.XMLHTTP')

For other browsers:

The copy code is as follows:

XmlHttp = new XMLHttpRequest ()

Different browsers have different support for XMLHttpRequest objects in javascript, so you need to make a judgment on a case-by-case basis.

XMLHttpRequest object related methods

Open request

The copy code is as follows:

XMLHttpRequest.open (delivery mode, address, whether or not asynchronous request)

Ready for execution

The copy code is as follows:

XMLHttpRequest.onreadystatechange

Get the execution result

The copy code is as follows:

XMLHttpRequest.responseText

A simple example of php+Ajax:

The first is the test.js file:

The copy code is as follows:

Var xmlHttp

Function S_xmlhttprequest () {

If (window.ActiveXObject) {

XmlHttp=new ActiveXObject ('Microsoft.XMLHTTP')

} else if (window.XMLHttpRequest) {

XmlHttp=new XMLHttpRequest ()

}

}

Function php100 (url) {

S_xmlhttprequest ()

XmlHttp.open ("GET", "do.php?id=" + url,true)

XmlHttp.onreadystatechange=byphp

XmlHttp.send (null)

}

Function byphp () {

Var byphp100=xmlHttp.responseText

Document.getElementById ('php100') [xss_clean] = byphp100

}

Then there is the file that performs the php operation, do.php

The copy code is as follows:

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