# Understanding Ajax / Javascript

**URL:** <https://forum.kirupa.com/t/understanding-ajax-javascript/266603>\
**Category:** web dev\
**Created:** [July 22, 2008, 4:11pm UTC](https://forum.kirupa.com/t/understanding-ajax-javascript/266603 "2008-07-22T16:11:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![basefour](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/basefour/32/3444_2.png) [@basefour](https://forum.kirupa.com/u/basefour)\
**Post date:** [July 22, 2008, 4:11pm UTC](https://forum.kirupa.com/t/understanding-ajax-javascript/266603/1 "2008-07-22T16:11:30Z")

</div>

I hope someone can point out what is wrong with my thinking here.

I’m confused about some basics with Javascript. At the bottom of my HTML page, I have a script that calls an initialization function on window.onload. This function preps the page and calls another function for creating an XMLHttp object. Then I assign a function to an onchange even for a dropdown box that utilizes the XMLHttp object created in the previous function.

I cannot get this script to work. What I am confused about is how you pass objects and values to functions assigned to events, for example:

months.onchange = updateDays(‘myvalue’)

will not work as it executes the funciton immediately. How do I get this function to see the XMLHttp object without making it global?

Thanks in advance.
