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 9024903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:08:26+00:00 2026-06-16T06:08:26+00:00

I have a method I’m trying to write that can post data to a

  • 0

I have a method I’m trying to write that can post data to a php file and get the results and return the output in a variable. For some reason, my block of code is not working.

function post_get(){

var result = null;

$.post("modules/data.php", { "func": "getNameAndTime" },
function(data){
    result = JSON.parse(data);
}, "json");


return result;
}

I get this error when using this method

SyntaxError: JSON Parse error: Unexpected identifier “undefined”

  • 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-06-16T06:08:27+00:00Added an answer on June 16, 2026 at 6:08 am

    If your server returns proper JSON encoded output and sets the correct headers (Content-Type: application/json), you can use data immediately:

    $.post("modules/data.php", {
        "func": "getNameAndTime"
    },
    function(data){
        console.log(data);
    }, "json");
    
    // btw, at this point in the code you won't have access to the return value
    

    In fact, even if it didn’t return proper data, the console.log(data) should provide you with enough information to figure out why it wasn’t working in the first place.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have method in my BLL that interacts with the database and retrieves data
I have a tree structure that I am trying to use a recursive method
I have method getBuses on my RESTful webservice (Rails). That method needs to return
We have method that looks like this : public String getCommandString(Object...args) { return this.code
I wrote some service that have method that get image ( byte[] ) as
I have method which updating data in database from CSV. csv_text = File.read(#{Rails.root}/db/seed/books.csv) csv
I have method that returns Drawable , and if its Bitmap object is recycled
I have method that returned NSManagedObject and I don't know what kind of NSManagedObject
I have method that returns module path of given class name def findModulePath(path, className):
I have method in a class that I need to make sure is only

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.