Also, I think it's more common to use document.getElementById instead of getElementByName. I don't know if it has something to do with browser compatibility, standards or something like that.. but all the examples I see all the time are using getElementById. Of course, to use getElementById you should set the id=".." property of the element instead of the name=".." property.
You have to use IdKey without the single quotes. IdKey is a variable.. you want the value stored inside it then you have to use it without the quotes. The way you're doing the browser is searching for an element with the id property set to IdKey (id="IdKey").
Edit: I forgot the part where you say the alert(IdKey) is outputting "undefined". Did you change the call to ajaxFunction() to pass the id of the element you want to update?