> I'd like to think I'm getting pretty good with ajaxForm, but > apparently not. > > I've got a form submitting, and it is supposed to send the response > to an element on the page, and leave the form in place. > > However, what's happening is that the form which it is submitted from > is being replaced. > > The "loading" text goes into the correct place and the 'alert' in the > success get's triggered, but the #holdBands div does not recieve the > response. > > here's the jquery code > [code] > var options = { > target: '#filterList', > beforeSubmit: submitFilter, > success: replaceFiltered, > type: 'post' > }; > > > $('#filterList').submit(function() { > $(this).ajaxSubmit(options); > return false; > }); > > function submitFilter(formData, jqForm, options) { > var queryString = $.param(formData); > $('#holdBands').html('<div>loading</div>'); > > } > > function replaceFiltered(options, responseText) { > $('#holdBands').html(responseText); > alert('triggered'); > > } > [/code] > > and a clip of my html incase it helps > > [code] > <form id="filterList" action="processes/showList.php" action="post"> > <select name="genre"> > <option value="this">filter</option> > </select> > </form> > <div class="nowPlaying"></div> > <span class="holdPlayer" id="holdPlayer"></span> > </div> > > <div id="holdBands"></div> > [/code] >
The 'target' option tells the plugin where to put the response, so you don't need to use the success handler (replaceFiltered) to do that. You can change your code to the following: var options { target: '#holdBands', beforeSubmit: submitFilter, type: 'post' }; $('#filterList').submit(function() { $(this).ajaxSubmit(options); return false; }); Or, more succinctly using ajaxForm: $('#filterList').ajaxForm({ target: '#holdBands', beforeSubmit: submitFilter, type: 'post' }); If you want to manage the response yourself then do not use the form plugin's 'target' option. In that case you can use your replaceFiltered function, but note that the correct arguments are shown below: function replaceFiltered(responseText, statusText) { $('#holdBands').html(responseText); alert('triggered'); } Mike