Ajax is "asynchronous", which is to say that you make the call to get the data, then it could take a few seconds for it to appear. During that time JavaScript code keeps going. So your code for "populate fields" most executes before the page snippet is actually loaded.
What you need to do is: function addActivity(activity, name, id) { // load activity snippet $(#activity).load('activity.html', function() { // populate fields in a form $('#ModName').val(name); $('#ModID').val(id); }); } The callback function (that in this case is the second parameter in the load function) gets called once snippet has actually returned. Be aware that if the loading fails the callback function still gets called. If you want more control you'll need to use the $.ajax() function. http://docs.jquery.com/Ajax/jQuery.ajax#options Karl Rudd On Mon, Feb 16, 2009 at 5:05 PM, jhm <jmay...@gmail.com> wrote: > >> You'll probably need to supply a snippet of the relevant bit of your >> code. It could be a number of things. > > Is this enough? > > function addActivity(activity, name, id) > { > // load activity snippet > $(#activity).load('activity.html'); > > // populate fields in a form > $('#ModName').val(name); > $('#ModID').val(id); > } > > >> Make sure you're doing the modifications to the loaded HTML (which >> will be located in the element you've chosen) in the callback >> function. > > Maybe this is where I'm going wrong. I'm trying to modify specific ids > in the document (which I assumed now includes the freshly loaded > code). > > Thanks! >