views:

35

answers:

1

When you use Google Videos, you will notice the right part of the page stays still when you search videos on the left. How is it implemented?

A: 

using ajax

http://www.google.com/search?q=ajax+tutorial

edit:

function $(id) { return document.getElementById(id); }

function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;  
}

function AJAX_GetAsinc(ajax, id, url) {
  ajax.abort();
  function statechange() {
    if ((ajax.readyState==4) && (ajax.status==200)) $(id).innerHTML=ajax.responseText;
  }
  ajax.open('GET', url, true);
  ajax.onreadystatechange = statechange;
  ajax.send(null);
}

usage:

var a = getHTTPObject();
AJAX_GetAsinc(a, 'YOUR_DIV_ID', 'mycontent.php');

or:

use jQuery or your favourite framework/library

Hope it's specific enough

Pedro Ladaria
Please be specific.
Steven
ajax_search.post();ajax_search.onresponse(leftdiv.replace());//anything more detailed is implementation specific, see the GV page source for **exact** details
Piskvor