Online Book Reader

Home Category

HTML, XHTML and CSS All-In-One for Dummies - Andy Harris [322]

By Root 1561 0
” + petName + “

”);

$(“#output”).append(“

”);

for (detail in pet){

$(“#output”).append(“

” + detail + “<\/dt>”);

$(“#output”).append(“

” + pet[detail] + “<\/dd>”);

} // end for

$(“#output”).append(“<\/dl>”);

} // end for

} // end processResults

1. Create the callback function.

This function expects a data parameter (like most AJAX requests). In this case, the data object contains a complete JSON object encapsulating all the data from the request.

2. Clear the output.

I replace the output with a series of definition lists. Of course, you can format the output however you wish.

$(“#output”).text(“”);

3. Step through each petName in the list.

This special form of the for loop finds each element in a list. In this case, it gets each pet name found in the data element:

for(petName in data){

4. Extract the pet as a variable.

The special form of for loop doesn’t retrieve the actual pets but rather the key associated with each pet. Use that pet name to find a pet and make it into a variable using an array lookup:

var pet = data[petName];

5. Build a heading with the pet’s name.

Surround the pet name with

tags to make a heading and append this to the output:

$(“#output”).append(“

” + petName + “

”);

6. Create a definition list for each pet.

Begin the list with a

tag. Of course, you can use whichever formatting you prefer, but I like the definition list for this kind of name/value data:

$(“#output”).append(“

”);

7. Get the detail names from the pet.

The pet is itself a JSON object, so use another for loop to extract each of its detail names (animal, breed, note):

for (detail in pet){

8. Set the detail name as the definition term.

Surround each detail name with a

pair. (Don’t forget to escape the slash character to avoid an XHTML validation warning.)

$(“#output”).append(“

” + detail + “<\/dt>”);

9. Surround the definition value with

.

This provides appropriate formatting to the definition value:

$(“#output”).append(“

” + pet[detail] + “<\/dd>”);

10. Close the definition list.

After the inner for loop is complete, you’re done describing one pet, so close the definition list:

$(“#output”).append(“

” + pet[detail] + “
”);

Book VIII

Moving from Pages to Sites

Chapter 1: Managing Your Servers

In This Chapter

Understanding the client-server relationship

Reviewing tools for client-side development

Gathering server-side development tools

Installing a local server with XAMPP

Setting essential security settings

Choosing a remote server

Managing the remote servers

Choosing and registering a domain name


Web pages are a complex undertaking. The basic Web page itself isn’t too overwhelming, but Web pages are unique because they have meaning only in the context of the Internet — a vastly new undertaking with unique rules.

Depending where you are on your Web development journey, you may need to understand the entire architecture, or you may be satisfied with a smaller part. Still, you should have a basic idea of how the Internet works and how the various technologies described in this book fit in.


Understanding Clients and Servers

A person using the Web is a client. You can also think of the user’s computer or browser as the client. Clients on the Internet have certain characteristics:

♦ Clients are controlled by individual users. You have no control over what kind of connection or computer the user has. It may not even be a computer but may be instead a cellphone or (I’m not kidding) refrigerator.

♦ Clients have temporary connections. Clients typically don’t have permanent connections to the Internet. Even if a machine is on a permanent network, most machines used as clients have temporarily assigned addresses that can change.

♦ Clients might have wonderful resources. Client machines may have multimedia capabilities, a mouse, and real-time interactivity with the user.

♦ Clients are limited. Web browsers and other client-side

Return Main Page Previous Page Next Page

®Online Book Reader