...

View Full Version : AJAX Request returns undefined...



danny5uk
04-07-2011, 06:59 PM
Hello,

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
to:

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

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

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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum