Saturday, April 07, 2007

Difference between <div> and <span>

1.The tag cant do any formatting of it's own.
2.It simply tells the browser which styles are applied whatever in the span tag.
3.It cant define any logical division of the document.


<div>

1.It includes the paragraph break.
2.it defines the logical division of the document.
AJAX stands for Asynchronous JavaScript And XML.

This technology is used to reduce the bandwidth and time of the user.

AjAX is combination of javascript and HTTP Request.In this technique the http request is created as xml (XMLHttpRequest).

if you want to use the technology called ajax,if you can create the XMLHttpRequest.
The below code is used to create the XMLHttpRequest.

function createXMLReq()
{
var XMLReq;
if(window.XMLHttpRequest)
{
try{
XMLReq = new XMLHttpRequest();
}
catch(e){

XMLReq = false;
}
}
elseif(window.ActveXobject)

{
try{
XMLReq = new ActiveXobject("micrfosoft.XMLHTTP");
}
catch(e)
{
XMLReq = false;
}
}

return XMLReq;

}

The above code is used to create the XMLHttpRequest.

using the open keyword you can call any serverside file with querystring.

For Example:

Req =
createXMLReq();

Req.open('method','url') - [method = Get/post][URL = Requested URL]

You can check the state of the Request by using the following code.

Req.onreadystatchange

You can get the response text by using responseText


There are several states are there.

0 - uninitialized.
1 - Loading
2 - loaded.
3 - Interactive.
4 - complete.







DOM (Document Object Model) in PHP5

In php5 DOM is an default extension.
It is used to create the xml/xhtml file in php.You can create the DOM object using the follwoing line.
$doc = new DomDocument();

By using the above object you can easily create the element by using the below code

$newEle = $doc->createElement('elementName'); [elementName - Variable]

After creating the element you can append the element as a child to other element.

$doc->appendChild($newEle);

The above code append the element as a child in the root.If you want to append the element as a child in particular element.
For example:

$dom = new
DomDocument();
$ele = $dom->createElement('html');
$chdEle = $dom->createElement('body');
$appEle = $ele->appendChild($chdEle);

$dom->appendChild($ele);

In the above code First the <html> and <body> elements are created,After that the body element is added as a child in html element.