Link to home
Start Free TrialLog in
Avatar of Sucao
Sucao

asked on

Need a way to send multiple data for $.post()

I need to send some data to a php script. Some of the data is coming from a textarea and some of it is coming from a variable (advice_ID) defined earlier in the javascript. Below is the code that I am using trying to send the data.

when I leave out the "+ {ID : advice_ID}" the code inputs form_data fine but I need to send that advice_ID.

when I leave in "+ {ID : advice_ID}" the code adds "[object Object]" to the end of the form_data.

don't know if that helps you diagnose the problem.
$.getJSON('../advice/php/get_advice_start.php', {ID : top.window.location.hash.substring(1)}, process_advice);
                        function process_advice(data) {
advice_ID = data.id;
}
 
$('#comment_form').submit(function() {
var form_data = $(this).serialize();
                        $.post('../advice/php/post_comment.php', form_data + {ID : advice_ID}, comment_callback);
                                                        function comment_callback(data) {
                                        }
                        return false;
                                                                   
});

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of alien109
alien109
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sucao
Sucao

ASKER

thanks alien109 that did the trick