Tuesday, February 2, 2010

Why the need for XHTML?

If a script in an HTML document is not well formed, small devices like mobile phones fail to display the content properly. Also, upgrading all the browsers to support XML is a timely affair. An intermediate solution is XHTML that is a combination of HTML and XML. In XTML the content has to be well formed so that there is no bad HTML.

XHTML vs HTML

XHTML
Elements must be properly nested
Elements must be closed
Elements must be in lowercase
Documents must have one root element
HTML
Elements need not be properly nested
Elements need not be always closed
Elements need not be in lowercase
Documents need not have one root element

Explain the XHTML syntax rules.

Some Syntax rules that need to be followed with XHTML are:
That Attribute names must be in lower case, their values must be in quotes and their minimization is done away from usage.
Also the ‘name’ attribute has been replaced by the ‘id’ attribute. The XHTML DTD defines mandatory elements.

What is the XMLHttpRequest Object?

The XMLHttpRequest object is used to connect to the server through http. Scripts use it to do so programmatically. 
The EventTarget interface needs to be implemented if an object implements the XMLHttpRequest interface. Also, an XMLHttpRequest() constructor needs to be provided by objects that implement the Window interface.

Explain common XMLHttpRequest Object Properties. i.e. onreadystatechange, readyState, responseText, responseXML, status, statusText. 

  • The ‘onreadystatechange’ property fires at every state change event.
  • The ‘readyState’ property is an object status integer. It uses the integers 0 to 4 for uninitialized, loading, loaded, interactive and complete states.
  • The ‘responseText’ property is a string version of data returned from server process.
  • The ‘responseXML’ property is DOM-compatible document object of data returned from server process.
  • The ‘status’ property is for returning numeric codes from the server like error codes, etc.
  • The ‘statusText’ property is used for string messages that accompany the status code.

Explain common XMLHttpRequest Object Methods.

  • The abort() is used to stop the current request.
  • The getAllResponseHeaders() method is used to return the full set of headers as a string.
  • The getResponseHeader("headerLabel") method is used to return the string value of a single header label.
  • The open("method", "URL"[, asyncFlag[, "userName"[, "password"]]]) is used to assign the destination URL, method, and other optional attributes of a request.
  • The send(content) method transmits the request, optionally with postable string or the data of DOM object.
  • The setRequestHeader("label", "value") method is used to assign a label/value pair to the header to be sent with a request.

0 Comments: