View

Ajax response handler

  1. function ajaxRequest()
  2. {
  3.         var opt = ‘s=whatever you want to pass’;
  4.         var page = ‘ajax_page.php’;
  5.         var http = createRequestObject();
  6.         http.onreadystatechange = function()
  7.         {
  8.                 if((http.readyState == 4) && (http.status == 200))
  9.                 {
  10.                         var text = http.responseText;
  11.                 }
  12.         }
  13.         http.open(‘POST’, page, true);
  14.         http.setRequestHeader(“Content-type”, “application/x-www-form-urlencoded”);
  15.         http.setRequestHeader(“Content-length”, opt.length);
  16.         http.setRequestHeader(“Connection”, “close”);
  17.         http.send(opt);
  18. }

Note

Handles response from an ajax request.

You may also like