PDA

View Full Version : Send Data with jQuery $.post()?



Aurora078
10-07-2010, 08:34 PM
Ok, so i know how to send a post. My problem is, how can i send my data ( in this case a username and password ) to another page, and then get a response displayed in my div "output_"?
Any help will be much appreciated.

Zeggy
10-07-2010, 09:45 PM
var data = {
username: $("#username").val(),
password: $("#pasword").val()
}

$.post("page.php", data, callback_function);

function callback_function(data) {
//process return data here
$("#output").html(data);
}

There are lots of examples in the documentation...

Dave Macaulay
10-07-2010, 10:36 PM
Ok, so i know how to send a post. My problem is, how can i send my data ( in this case a username and password ) to another page, and then get a response displayed in my div "output_"?
Any help will be much appreciated.

No offence to you because you are learning and so on.. But this was really lazy.

The creators off jQuery didn't write a complete documentation on every function and how to use them just for their own amusement?
http://docs.jquery.com/Main_Page

Djkanna
10-08-2010, 06:58 AM
Also for this I'd use $.ajax({}); it's possibly a bit more expandable than the post helper.

Aurora078
10-08-2010, 01:08 PM
Also for this I'd use $.ajax({}); it's possibly a bit more expandable than the post helper.

I was thinking of using ajax strictly for the error function it allows that post doesnt.