Listing 1

create or replace function
wwv_flow_epg_include_mod_local(procedure_name in varchar2)
return boolean
is
begin
    -- return false; -- remove this statement when you modify this function
    --
    -- Administrator note: the procedure_name input parameter may be in the format:
    --
    --    procedure
    --    schema.procedure
    --    package.procedure
    --    schema.package.procedure
    --
    -- If the expected input parameter is a procedure name only, the IN list code shown below
    -- can be modified to itemize the expected procedure names. Otherwise you must parse the
    -- procedure_name parameter and replace the simple code below with code that will evaluate
    -- all of the cases listed above.
    --
    if upper(procedure_name) in (
	 'HR.AJAXE') then
        return TRUE;
    else
        return FALSE;
    end if;
end wwv_flow_epg_include_mod_local;

Listing 2

create or replace procedure ajax_xmlhtp(ctxt in number) as
  xml clob;
  chnk number := 4000;
begin
  owa_util.mime_header('text/xml');
  dbms_xmlgen.setnullhandling(ctxt, dbms_xmlgen.empty_tag);
  dbms_xmlgen.setprettyprinting(ctxt, false);
  xml := dbms_xmlgen.getxml(ctxt);
  for i in 1..ceil(length(xml)/chnk) loop
    htp.prn(dbms_lob.substr(xml, chnk+1, i+(i-1)*chnk));
  end loop;
  dbms_xmlgen.closecontext(ctxt);
  exception
    when others then
      htp.print('<?xml version="1.0"?>');
      htp.print('<ROWSET><ROW><INFO>No data found.</INFO></ROW></ROWSET>');
end;
/

Listing 3

create or replace procedure ajaxe(q varchar2, w varchar2 default '') as
  ctxt number;
  i number;
begin
  if q='count' then
    ajax_xmlhtp(dbms_xmlgen.newcontext('select count(*) "EMPLOYEES" from employees'));
  elsif q='search' then
    i := length(w);
    ctxt := dbms_xmlgen.newcontext('select * from employees where upper(substr(last_name, 0, :LEN))=upper(:PREFIX)
	 order by last_name');
    dbms_xmlgen.setbindvalue(ctxt, 'LEN', i);
    dbms_xmlgen.setbindvalue(ctxt, 'PREFIX', w);
    ajax_xmlhtp(ctxt);
  elsif q='fetch' then
    ajax_xmlhtp(dbms_xmlgen.newcontext('select * from employees'));
  elsif q='select' then
    ajax_xmlhtp(dbms_xmlgen.newcontext('select department_id, department_name from departments order by 2'));
  elsif q='dept' then
    ctxt := dbms_xmlgen.newcontext('select * from employees where department_id=:DEPT');
    dbms_xmlgen.setbindvalue(ctxt, 'DEPT', w);
    ajax_xmlhtp(ctxt);
  end if;
end;
/

Listing 4

function ajaxTable(xml) {
	document.getElementById('q').innerHTML = '';
	var rows = xml.documentElement.getElementsByTagName('ROW');
	var table = document.createElement('table');
	var tbody = document.createElement('tbody');
	table.setAttribute('border', '1');
	var tr = document.createElement('tr');
	for (var h=0; h<rows[0].childNodes.length; h++) {
		if (rows[0].childNodes[h].nodeType!=1) {
			continue;
		}
		var th = document.createElement('th');
		th.appendChild(document.createTextNode(rows[0].childNodes[h].ta gName));
		tr.appendChild(th);
	}
	tbody.appendChild(tr);
	for (var i=0; i<rows.length; i++) {
		var tr = document.createElement('tr');
		for (var j=0; j<rows[i].childNodes.length; j++) {
			if (rows[i].childNodes[j].nodeType!=1) {
				continue;
			}
			var td = document.createElement('td');
			if (rows[i].childNodes[j].childNodes.length!=0) {
				td.appendChild(document.createTextNode(rows[i].childNodes[j].firstChild.nodeValue));
			} else {
				td.appendChild(document.createTextNode('-'));
			}
			tr.appendChild(td);
		}
		tbody.appendChild(tr);
	}
	table.appendChild(tbody);
	document.getElementById('q').appendChild(table);
}


Listing 5

<table border="1">
<tbody>
<tr>
<th>HEADING1</th>
<th>HEADING2</th>
<th>...</th>
</tr>
<tr>
<td>ROW1, COLUMN1</td>
<td>ROW1, COLUMN2</td>
<td>ROW1, ...</td>
</tr>
...
</tbody>
</table>

Listing 6

var request = false;
try {
	request = new XMLHttpRequest();
} catch(e) {
	try {
		request = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e2) {
		request = new ActiveXObject("MSXML.XMLHTTP");
	}
}