using jquery $.post() for returning multiple values
Posted
by
Aninemity
on Stack Overflow
See other posts from Stack Overflow
or by Aninemity
Published on 2011-01-08T21:49:00Z
Indexed on
2011/01/08
21:53 UTC
Read the original article
Hit count: 122
Hi all
I am trying to use a $.post() in the following way:
$.post("file.php", { file_id: $(this).val()}, function(data){...}
The file.php
then does a database query and returns an array with a title, description and image reference.
What I want to do then is be able to update the .val()
for form fields for each. I understand how to do this on a single variable, it would just be the following:
$.post("file.php", { file_id: $(this).val()}, function(data){
$('#title').val(data);
}
But, how do I get the data returned to be recognizable in jquery as either separate variables or as an array?
Thanks in advance
© Stack Overflow or respective owner