Start studying Ajax. First day _ajax related

Source: Internet
Author: User
Start studying Ajax. First day

First of all, I am not suitable for the study program of the person, also do not like, because I am very careless, every time will write a lot of code wrong. But out of love for Dom,js,css, I started to study Ajax.

What is Ajax?
I answer: First of all, the four components of Ajax are [XMLHTTPREQUEST],[JAVASCRIPT],[DOM],[CSS]. These four things are not explained for the moment. The effect of these four things is [XMLHttpRequest] is responsible for communicating with the Web server, [Javascript] controlling the page by controlling [DOM], [CSS] doing page retouching, and of course being controlled by the image. This is Ajax. What I understand.

Here is an example!
The Hello page of Ajax! Hello the world!

CODE:
[Copy to Clipboard]
<title>hello.the world</title>

<style type= "Text/css" ><!--
. declared {color:red; font-size:14px;}
. programmed {color:blue; font-size:12px; font-weight:bold;}
--></style>

<script>
Window.onload=function () {
var hello=document.getelementbyid (' Hello '); Finding elements by ID
Hello.classname= ' declared ';

var Empty=document.getelementbyid (' empty ');
AddNode (Empty, "reader of");
AddNode (Empty, "Ajax in action!");

var children=empty.childnodes;
for (Var i=0;i<children.length;i++) {
Children[i].classname= ' programmed ';
}

Empty.style.border= ' solid green 2px '; Set the style directly for the node
Empty.style.width= "200px";
}

function AddNode (el,text) {
var childel=document.createelement ("div"); Create a new element
El.appendchild (Childel);
var txtnode=document.createtextnode (text); Creating text elements
Childel.appendchild (Txtnode);
}
</script>
<body>
<p id= "Hello" >Hello</p>
<div id= "Empty" ></div>
</body>
This example is the use of JavaScript to control the DOM, in the page to write content and the content of the page is decorated with CSS.

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.