Borut Flis
Borut Flis

Reputation: 16415

Send json to php through a form

$('<form method="post" action="login/makeLogin"><input type="hidden" name="fbphoto" value="'+image +
                    '"><input type="hidden" name="fbname" value="'+response.first_name +'"><input type="hidden" name="fbemail" value="'+response.email +'"><input type="hidden" name="fbid" value="'+response.id+
                    '"><input type="hidden" name="fbsurname" value="'+response.last_name +'"><input type="hidden" name="fbfriends" value="'+json +'"></form>').appendTo('body')

I create this form dynamicly with javascript. But when I try to send this form to a php function, it returns false when I try to access the fbfriends property the rest values work fine. The value of fbfriends is a string containing json, which I get using:

var json=JSON.stringify(response.friends);

If I dont stringify the json I get a string [Object object] when retrieving values in the php function. How can I send json through a form.

Upvotes: 2

Views: 241

Answers (1)

Isidro Moran
Isidro Moran

Reputation: 330

Your form only contains hidden items. Why don't you post the response values through $.ajax directly?

Upvotes: 1

Related Questions