View Full Version : AJAX Request returns undefined...

04-07-2011, 05:59 PM

I have the following Ajax request:

// store reference to the form
var $this = $('form#loginform');

// grab the url from the form element
var url = $this.attr('action');

// prepare the form data to send
var dataToSend = $this.serialize();

// the callback function

var callback = function(data){

document.getElementById('response').innerHTML = data

// now send the form and wait to hear back
$.get( url, dataToSend, callback, 'html' )

When I change:

document.getElementById('response').innerHTML = data

document.getElementById('response').innerHTML = url

document.getElementById('response').innerHTML = dataToSend

All is well, and the div contains either the contents of the form or the correct url etc. So I know the variables are working and storing correctly, but when I actually run it, the div either declares undefined, or remains blank.. :confused:

All help is appreciated.