I don't know what is in your "js/ajax.js" file, but that AJAX code looks wrong, to me. (It could be right, depending on what's in "ajax.js", but it just *FEELS* wrong.)
To test my theory, temporarily comment out that js/ajax.js inclusion and try coding it by hand:
function ajax_post( )
var ajax = window.XMLHttpRequest != null
? new XMLHttpRequest()
: new ActiveXObject("Microsoft.XMLHTTP");
ajax.open( "POST", "displayRec.php", true );
if (ajax.readyState==4 && ajax.status==200)
alert("Answer from AJAX: " + ajac.responseText );
ajax.send("keyid=" + keyid );
But in the process of writing that I saw your goof.
How hard will you kick yourself?
ajax.send("keyid=" . keyid );
On the other hand, look how small my AJAX code is. Is there really any need for "ajax.js"?