Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Storing response in input

Posted on 2016-08-25
4
Medium Priority
?
114 Views
Last Modified: 2016-08-25
I have a response from the Facebook API I'm trying to store in an input before submit.

I set it in a var which when console logged it shows all of the data I need.

I then try to set that into the value of the input field:
$("#fbPageLikes").val(fbPageLikes);

Open in new window


But then when it inserts into the database I only see [object][object].  How can I actually show the data there?
0
Comment
Question by:Nathan Riley
  • 2
  • 2
4 Comments
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 41770683
What do you see when you use alert(fbPageLikes) ?
0
 
LVL 12

Author Comment

by:Nathan Riley
ID: 41770686
Alert
0
 
LVL 12

Author Comment

by:Nathan Riley
ID: 41770690
In my console.log though I see this:

Console Log
0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 41770714
So it looks like fbPageLikes is a JavaScript object that contains an array named data.  The array is a collection of JavaScript objects, each with a few named elements.  You might try using JSON.stringify(fbPageLikes) in the JavaScript to make the information into a string for HTTP transport, and json_decode() in the PHP script.  After json_decode() use var_dump() to visualize the information sent by JavaScript.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to dynamically set the form action using jQuery.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question