phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


AJAX - Client Side: JavaScript Overview

Tag: AJAX, client side, javascript   Category: PHP Application
post: 03 Mar 2008 read: 327


AJAX Client Side Step By Step Tutorial - part 2: JavaScript is heart of AJAX. If you still don't know anything (I know absolutely, it is not you!), we will talk a little JavaScript over here. We will talk completely about javascript at others tutorial series (next time).

JavaScript program designed to run in a browser has to be attached to a document. Most at HTML or XHTML document. But, future, we can attach at XML, SVG, etc.

To include JavaScript on an html page, we have to use <script> tag. Because script is not only JavaScript, tell to browser by adding a type attribut with a value of text/javascript.Look line 8-10 below:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<script type="text/javascript">
   alert("It is me, JavaScript!");
</script>

</head>

<body>
</body>
</html>

Other choice, we can put JavaScript program to separate file. It is preferable because have several advantages:
- easier maintain
- reusable

Look example below:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<script type="text/javascript" src="example.js">
 
</script>

</head>

<body>
</body>
</html>

JavaScript file (named "example.js") will be downloaded by browser.



Series this article:
AJAX - Client Side: Techniques Introduction
AJAX - Client Side: JavaScript Overview
AJAX - Client Side: JavaScript and Document Object Model
AJAX - Client Side: JavaScript Events and the DOM
AJAX - Client Side: JavaScript, DOM, and CSS
AJAX - Client: XMLHttpRequest Object
AJAX - Client Side: Initiating Server Request Using XMLHttpRequest
AJAX - Client Side: Handling Server Response
AJAX - Client Side: Making Asynchronous Calls with XMLHttpRequest
AJAX - Client Side: Working with XML Structure
AJAX - Client Side: Processing XML Data use XMLHttpRequest
AJAX - Client Side: Simple Application for Process XML data

| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting