Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7635981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:33:42+00:00 2026-05-31T07:33:42+00:00

I have the below function erroring and its begin a real pain. For some

  • 0

I have the below function erroring and its begin a real pain.

For some reason it is saing postData is not defined on the lines marked with error. But I have defined postData and populated it with the returned json from get.php?? Is there something missing here.

<script>
 function postToFeed(shoeID) {

    $.post("get.php",{id: shoeID}, 
                function(data){
                               var postData = data;
                               }, "json");  

    var obj = {
      method: 'feed',
      link: 'https://developers.facebook.com/docs/reference/dialogs/',
      picture: 'http://fbrell.com/f8.jpg',
      name: postData.title, //ERROR
      caption: '<?=SHARE_CAPTION?>',
      description: postData.description //ERROR
    };

    function callback(response){
        if(response['post_id']){
            $.post("vote.php",{id: '<?=(isset($_POST['fbid'])? $_POST['fbid'] : $data['id'])?>', shoe: shoeID, type: 'share'}, 
                            function(score){
                            $("#shoe_"+shoeID).html(score)
                            }); 
        }
    }

    FB.ui(obj,callback);
  }
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T07:33:43+00:00Added an answer on May 31, 2026 at 7:33 am

    Since you have defined it inside the success handler of post it is not accessible. Define postData in the outer scope it will work fine.

    function postToFeed(shoeID) {
        var postData;//
        $.post("get.php",{id: shoeID}, 
                    function(data){
                                   postData = data;
                                   }, "json");  
    
    ....
    .... 
    

    One more thing to note here. You are using $.post which makes an ajax call asynchronously so even if you define postData in the outer scope it will not work because until the post request executes the postData is null or empty.

    So you should execute rest of the code inside the success handler of $.post. Try this.

    function postToFeed(shoeID) {
    
        $.post("get.php",{id: shoeID}, function(data){
          var postData = data;
          var obj = {
               method: 'feed',
               link: 'https://developers.facebook.com/docs/reference/dialogs/',
               picture: 'http://fbrell.com/f8.jpg',
               name: postData.title, //ERROR
               caption: '<?=SHARE_CAPTION?>',
               description: postData.description //ERROR
          };
    
          function callback(response){
            if(response['post_id']){
                $.post("vote.php",{id: '<?=(isset($_POST['fbid'])? $_POST['fbid'] : $data['id'])?>', shoe: shoeID, type: 'share'}, 
                                function(score){
                                $("#shoe_"+shoeID).html(score)
                                }); 
            }
          }
    
          FB.ui(obj,callback);
    
        }, "json"); //$.post-End 
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function that resembles the one below. I'm not sure how to
I have template function compare defined as below. #include<iostream> using namespace std; template<typename T>
I have written a pgsql function along the lines of what's shown below. How
I have below piece of code in my actionscript file (defined in a function)
I have some code for validating date below: function validateForm() { var errFound =
let say i have function like below function doSomethingNow(){ callSomethingInFutureNotExistNow(); } at the moment
I have written a function below: void trans(double x,double y,double theta,double m,double n) {
I have the following function below: public function setupHead($title){ $displayHead .='<!DOCTYPE html PUBLIC -//W3C//DTD
I have an example function below that reads in a date as a string
I have the below prog Object.prototype.inherit = function(baseConstructor) { this.prototype = (baseConstructor.prototype); this.prototype.constructor =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.