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

  • Home
  • SEARCH
  • 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 6575545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:24:00+00:00 2026-05-25T15:24:00+00:00

I get a response from the POST method. Inside I see the value, but

  • 0

I get a response from the POST method.
Inside I see the value, but after the POST method returns an empty value.
Why, hot fix this?

sample:

$.post('/news/add/', {parent: name, title: 'none'}, function(data){ 
 new_id = data;
 alert(new_id); //11
});
alert(new_id); //empty
  • 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-25T15:24:00+00:00Added an answer on May 25, 2026 at 3:24 pm

    Because you are making an asynchronous call the code is run in this order:

    1 - $.post('/news/add/', {parent: name, title: 'none'}, function(data){ 
       3 - new_id = data;
       4 - alert(new_id); //11
    });
    2 - alert(new_id); //empty
    

    You can only use the value returned by your post inside the callback function.

    The only other way to do this is to make the request synchronous. But that’s really not advised as it can lock out the browser waiting for the response.

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

Sidebar

Related Questions

After I get response from httpwebrequest, I'd like the cookies obtained to save for
I'm using the following in the web page but can't get a response from
I noticed that Feedzirra uses this regex to get the ETag from response header:
I am trying following, 1. Get response using Ajax from the users selection which
Can't get Location header from response at all. Wireshark says that i've got one:
Not certain if this will get much response due to the newness of Windows
EDIT: I've tagged this C in a hope to get more response. It's more
At the moment I'm using the post method like this $.ajax({ type: POST, url:
Hi i'm trying to retrieve response after passing some variables from javascript to php
Is there a way to get the responde headers from a web service call

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.