Ajax + PHP Quick Start and simple application

Source: Internet
Author: User
Introduction: Ajax is composed of HTML, JavaScript? The combination of technology, DHTML and DOM can transform clumsy Web interfaces into interactive Ajax applications. For Ajax, the core object is XMLHttpRequest. All Ajax operations cannot be separated from operations on this object. Create XMLHttpRequest

Introduction: Ajax is composed of HTML, JavaScript? The combination of technology, DHTML and DOM can transform clumsy Web interfaces into interactive Ajax applications. For Ajax, the core object is XMLHttpRequest. All Ajax operations cannot be separated from operations on this object. Create XMLHttpRequest

Introduction:

Ajax is composed of HTML, JavaScript? The combination of technology, DHTML and DOM can transform clumsy Web interfaces into interactive Ajax applications.

For Ajax, the core object is XMLHttpRequest. All Ajax operations cannot be separated from operations on this object.

Create an XMLHttpRequest object

For ie browsers:

xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');


For other browsers:

xmlHttp = new XMLHttpRequest();


Different browsers have different support for XMLHttpRequest objects in javascript, so you need to make a judgment based on the situation.

XMLHttpRequest object related methods

Open request

XMLHttpRequest. open (transfer method, address, asynchronous request or not)

Ready for execution

XMLHttpRequest.onreadystatechange

Obtain execution results

XMLHttpRequest.responseText


A simple php + Ajax example:

The first is the test. js file:

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').innerHTML=byphp100;}


Then the file that executes the php operation, do. php

 


The frontend display page, test.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.