Saturday, May 30, 2009

What is AJAX

Ajax, sometimes written as AJAX (shorthand for asynchronous JavaScript and XML), is a group of interrelated web development techniques used on the client-side to create interactive web applications or rich Internet applications.

With Ajax, web applications can retrieve data from the server asynchronously in the background without interfering with the display and behavior of the existing page. The use of Ajax has led to an increase in interactive animation on web pages and better quality of Web services thanks to the asynchronous mode. Data is retrieved using the XMLHttpRequest object. Despite the name, the use of JavaScript and XML is not actually required, nor do the requests need to be asynchronous.

Advantages

* In many cases, related pages on a website consist of much content that is common between them. Using traditional methods, that content would have to be reloaded on every request. However, using Ajax, a web application can request only the content that needs to be updated, thus drastically reducing bandwidth usage and load time.

* The use of asynchronous requests allows the client's Web browser UI to be more interactive and to respond quickly to inputs, and sections of pages can also be reloaded individually. Users may perceive the application to be faster or more responsive, even if the application has not changed on the server side.

* The use of Ajax can reduce connections to the server, since scripts and style sheets only have to be requested once.

* State can be maintained throughout a Web site. JavaScript variables will persist because the main container page need not be reloaded.

Disadvantages

* Pages dynamically created using successive Ajax requests do not automatically register themselves with the browser's history engine, so clicking the browser's "back" button may not return the user to an earlier state of the Ajax-enabled page, but may instead return them to the last full page visited before it. Workarounds include the use of invisible IFrames to trigger changes in the browser's history and changing the anchor portion of the URL (following a #) when AJAX is run and monitoring it for changes.

* Dynamic web page updates also make it difficult for a user to bookmark a particular state of the application. Solutions to this problem exist, many of which use the URL fragment identifier (the portion of a URL after the '#') to keep track of, and allow users to return to, the application in a given state.

* Because most web crawlers do not execute JavaScript code, web applications should provide an alternative means of accessing the content that would normally be retrieved with Ajax, to allow search engines to index it.

* Any user whose browser does not support Ajax or JavaScript, or simply has JavaScript disabled, will not be able to use its functionality. Similarly, devices such as mobile phones, PDAs, and screen readers may not have support for JavaScript or the XMLHttpRequest object.[citation needed] Also, screen readers that are able to use Ajax may still not be able to properly read the dynamically generated content. The only way to let the user carry out functionality is to fall back to non-JavaScript methods. This can be achieved by making sure links and forms can be resolved properly and rely not solely on Ajax. In JavaScript, form submission could then be halted with "return false".

* The same origin policy prevents some Ajax techniques from being used across domains, although the W3C has a draft that would enable this functionality.

* Ajax opens up another attack vector for malicious code that web developers might not fully test for.

HTTP Status Codes: 3xx Redirection

The client must take additional action to complete the request.

This class of status code indicates that further action needs to be taken by the user agent in order to fulfil the request. The action required may be carried out by the user agent without interaction with the user if and only if the method used in the second request is GET or HEAD. A user agent should not automatically redirect a request more than five times, since such redirections usually indicate an infinite loop.

300 Multiple Choices

Indicates multiple options for the resource that the client may follow. It, for instance, could be used to present different format options for video, list files with different extensions, or word sense disambiguation.

301 Moved Permanently

This and all future requests should be directed to the given URI.

302 Found

This is the most popular redirect code, but also an example of industrial practice contradicting the standard. HTTP/1.0 specification (RFC 1945 ) required the client to perform a temporary redirect (the original describing phrase was "Moved Temporarily"), but popular browsers implemented it as a 303 See Other. Therefore, HTTP/1.1 added status codes 303 and 307 to disambiguate between the two behaviors. However, the majority of Web applications and frameworks still use the 302 status code as if it were the 303.

303 See Other (since HTTP/1.1)

The response to the request can be found under another URI using a GET method. When received in response to a PUT, it should be assumed that the server has received the data and the redirect should be issued with a separate GET message.

304 Not Modified

Indicates the resource has not been modified since last requested. Typically, the HTTP client provides a header like the If-Modified-Since header to provide a time against which to compare. Utilizing this saves bandwidth and reprocessing on both the server and client.

305 Use Proxies (since HTTP/1.1)

Many HTTP clients do not correctly handle responses with this status code, primarily for security reasons.

307 Temporary Redirect (since HTTP/1.1)

In this occasion, the request should be repeated with another URI, but future requests can still use the original URI. In contrast to 303, the request method should not be changed when reissuing the original request. For instance, a POST request must be repeated using another POST request.

Friday, May 29, 2009

HTTP Status Codes: 4xx Client Error

The request contains bad syntax or cannot be fulfilled.

The 4xx class of status code is intended for cases in which the client seems to have erred. Except when responding to a HEAD request, the server should include an entity containing an explanation of the error situation, and whether it is a temporary or permanent condition. These status codes are applicable to any request method. User agents should display any included entity to the user. These are typically the most common error codes encountered while online.

400 Bad Request: The request contains bad syntax or cannot be fulfilled.

401 Unauthorized: Similar to 403 Forbidden, but specifically for use when authentication is possible but has failed or not yet been provided. See Basic access authentication and Digest access authentication.

402 Payment Required: The original intention was that this code might be used as part of some form of digital cash or micropayment scheme, but that has not happened, and this code has never been used.

403 Forbidden: The request was a legal request, but the server is refusing to respond to it. Unlike a 401 unauthorized response, authenticating will make no difference.

404 Not Found: The requested resource could not be found but may be available again in the future. Subsequent requests by the client are permissible.

405 Method Not Allowed: A request was made of a resource using a request method not supported by that resource; for example, using GET on a form which requires data to be presented via POST, or using PUT on a read-only resource.

406 Not Acceptable: The requested resource is only capable of generating content not acceptable according to the Accept headers sent in the request.

407 Proxy Authentication Required

408 Request Timeout: The server timed out waiting for the request.

409 Conflict: Indicates that the request could not be processed because of conflict in the request, such as an edit conflict.

410 Gone: Indicates that the resource requested is no longer available and will not be available again. This should be used when a resource has been intentionally removed; however, it is not necessary to return this code and a 404 Not Found can be issued instead. Upon receiving a 410 status code, the client should not request the resource again in the future. Clients such as search engines should remove the resource from their indexes.

411 Length Required: The request did not specify the length of its content, which is required by the requested resource.

412 Precondition Failed: The server does not meet one of the preconditions that the requestor put on the request.

413 Request Entity Too Large: The resource that was requested is too large to transmit using the current protocol.

414 Request-URI Too Long: The URI provided was too long for the server to process.

415 Unsupported Media Type: The request did not specify any media types that the server or resource supports. For example the client specified that an image resource should be served as image/svg+xml, but the server cannot find a matching version of the image.

416 Requested Range Not Satisfiable: The client has asked for a portion of the file, but the server cannot supply that portion (for example, if the client asked for a part of the file that lies beyond the end of the file).

417 Expectation Failed: The server cannot meet the requirements of the Expect request-header field.

422 Unprocessable Entity: The request was well-formed but was unable to be followed due to semantic errors.

423 Locked: The resource that is being accessed is locked

424 Failed Dependency: The request failed due to failure of a previous request

425 Unordered Collection

426 Upgrade Required: The client should switch to TLS/1.0.449 Retry With

Thursday, May 28, 2009

HTTP Status Codes : 5xx Server Error

As you must be aware that HTTP calls over the internet get different responses. Most common is 404 when you are not connected to Internet of your proxy has blocked a particular host.

The first digit of the status code specifies one of five classes of response; the bare minimum for an HTTP client is that it recognizes these five classes.

1xx: Informational
2xx: Success
3xx: Redirection
4xx: Client Errors
5xx: Server Errors

Here we are going to talk about 5xx (Server Errors).


The server failed to fulfill an apparently valid request.

Response status codes beginning with the digit "5" indicate cases in which the server is aware that it has encountered an error or is otherwise incapable of performing the request. Except when responding to a HEAD request, the server should include an entity containing an explanation of the error situation, and indicate whether it is a temporary or permanent condition. Likewise, user agents should display any included entity to the user. These response codes are applicable to any request method.


So if you are a tester and get 5xx http code, you need to assign the bug to Server Team :)

500 Internal Server Error

A generic error message, given when no more specific message is suitable.

501 Not Implemented

The server either does not recognize the request method, or it lacks the ability to fulfil the request.

502 Bad Gateway

The server was acting as a gateway or proxy and received an invalid response from the upstream server.

503 Service Unavailable

The server is currently unavailable (because it is overloaded or down for maintenance). Generally, this is a temporary state.

504 Gateway Timeout

The server was acting as a gateway or proxy and did not receive a timely request from the upstream server.

505 HTTP Version Not Supported

The server does not support the HTTP protocol version used in the request.

506 Variant Also Negotiates

507 Insufficient Storage

509 Bandwidth Limit Exceeded


510 Not Extended

Further extensions to the request are required for the server to fulfill it.

Wednesday, May 20, 2009

Tips for an Ergonomic Computer Workstation:


For last few weeks I have been going through severe back pain and its creating lot of problems in my work and personal life-style. So I was going to through some tips about the sitting posture while working. Here are few tips I found and I will also share my personal experience...


Tips for an Ergonomic Computer Workstation:

  1. Use a good chair with a dynamic chair back and sit back in this
  2. Top of monitor casing 2-3" (5-8 cm) above eye level
  3. No glare on screen, use an optical glass anti-glare filter where needed
  4. Sit at arms length from monitor
  5. Feet on floor or stable footrest
  6. Use a document holder, preferably in-line with the computer screen
  7. Wrists flat and straight in relation to forearms to use keyboard/mouse/input device
  8. Arms and elbows relaxed close to body
  9. Center monitor and keyboard in front of you
  10. Use a negative tilt keyboard tray with an upper mouse platform or downward tiltable platform adjacent to keyboard
  11. Use a stable work surface and stable (no bounce) keyboard tray
  12. Take frequent short breaks (microbreaks)


Apart from above I also want to share following things:

- While working don't sit for a very long time. Take breaks after every 15-20 minutes.
- Walk around your workspace for some time but make sure you are not disturbing others.
- Make a routine of doing some body excercises daily.
- Good rest is also important.