Suppose that you want to design a new Ajax application, or update a legacy web application to include Ajax techniques. How do you go about it? First you need to decide what page events and user actions will be responsible for causing the sending of an asynchronous HTTP request. You may decide, for example, that the action of moving the mouse cursor over an image will result in a request being sent to the server to retrieve further information about the subject of the picture, or that the clicking of a button will generate a server request for information with which to populate the fields on a form.
This is featured post 1 title
To set your featured posts, please go to your theme options page in wp-admin. You can also disable featured posts slideshow if you don't wish to display them.
This is featured post 2 title
To set your featured posts, please go to your theme options page in wp-admin. You can also disable featured posts slideshow if you don't wish to display them.
This is featured post 3 title
To set your featured posts, please go to your theme options page in wp-admin. You can also disable featured posts slideshow if you don't wish to display them.
The Constituent Parts of Ajax
The XMLHTTPRequest Object
When you click on a hyperlink or submit an HTML form, you send an HTTP request to the server, which responds by serving to you a new or revised page. For your web application to work asynchronously, however, you must have a means to send HTTP requests to the server without an associated request to display a new page. You can do so by means of the XMLHTTPRequest object. This JavaScript object is capable of making a connection to the server and issuing an HTTP request without the necessity of an associated page load.
Introducing Ajax
To improve the user’s experience, you need to add some extra capabilities to the traditional page-based interface design. You want your user’s page to be interactive, responding to the user’s actions with revised content, and be updated without any interruptions for page loads or screen refreshes. To achieve this, Ajax builds an extra layer of processing between the web page and the server.
The Need for Ajax
In the following parts of the book, we shall discuss each of the core components in detail. Before discussing the individual components, though, let’s look in more detail at what we want from our Ajax application.
Traditional Versus Ajax Client-Server Interactions
Anatomy of an Ajax Application
What You’ll Learn :
Learn about the individual building blocks of Ajax and how they fit together to form the architecture of an Ajax application. Subsequent chapters will examine these components in more detail, finally assembling them into a working Ajax application.
Adding Lines
A horizontal line, or horizontal rule as it is named in HTML, is one of the easiest tags to use. You can insert the <hr /> tag anywhere in your document to insert a horizontal line that extends across the space available. Take a look at the following sample HTML. It shows three <hr> tags: two used as a section break between text and the other used inside a table cell. Figure 2.8 shows how they appear in the browser.
Formatting Text with Styles
Text is the most important element of any Web page. Without text, there is nothing on the page to help people decide whether it’s worth coming back. Text on an HTML page is structured by the <body>, <p>, <td>, <tr>, <th>, <h1> <h6>, and <li> tags (among others). You can add your own style preferences to each of these tags using the style properties shown.
In the following example, we’ve added some embedded style elements that set the font, font size, and font color for the body text of a basic HTML page. You can see how those styles change the appearance of the document in the browser.
Add a Little class
As the old saying goes, rules are made to be broken. What if you don’t want every single h1 heading in your document to be white on a black background? Maybe you want every other h1 heading to be yellow on a white background. Let me introduce you to the class attribute. You can apply this attribute to almost every HTML tag, and it’s almost like creating your own tags.
Defining the Rules
Style sheet rules are made up of selectors (the HTML tags that receive the style) and declarations (the style sheet properties and their values). In the following example, the selector is the body tag and the declaration is made up of the style property (background) and its value (black). This example sets the background color for the entire document to black.








