Alternatively, using Prototype:
Event.observe(this, 'load', function() { new Ajax.Request(... ) );
Or even better, define the function elsewhere rather than inline, and then:
Event.observe(this, 'load', functionName );
It is not necessary to specifically use jQuery or Prototype, but it is recommended to utilize some sort of library for event handling. Either library will manage event handling more consistently than onload, making it easier to process the Ajax call. If you prefer utilizing the body onload attribute, you can simply call the same function as shown in these examples (
onload="javascript:functionName();"
).
If your database update does not rely on the page being fully rendered, why wait until then? You could include a call to the Ajax-calling function at the end of the JavaScript on the page for nearly the same effect.