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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:25:35+00:00 2026-05-31T06:25:35+00:00

I wish to use the jQuery.post class to return (not alert) the response within

  • 0

I wish to use the jQuery.post class to return (not alert) the response within a function.

The following gives an alert with the appropriate value:

function test_func() {
    $.post("test.php", { cmd: "testing" }, function (data) { alert(data); })
}

(displays alert with appropriate value)

I tried the following:

function test_func() {
    return $.post("test.php", { cmd: "testing" }, function (data) { return data; })
}

(returned object)

function test_func() {
    var tmp;
    $.post("test.php", { cmd: "testing" }, function (data) { tmp=data; })
    return tmp;
}

(returned undefined)

var tmp;

function setTmp(n) {
    tmp=n;
}

function test_func() {
    t=$.post("test.php", { cmd: "testing" }, function (data) { setTmp(data); })
}

(returned undefined)

function test_func() {
    t=$.post("test.php", { cmd: "testing" })
    return t.responseText;
}

(returned undefined)

So what’s the deal? How can I make “test_func()” return the data response text?

  • 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-31T06:25:36+00:00Added an answer on May 31, 2026 at 6:25 am

    The deal is ajax is asynchronous one possible solution is to set it as sync like

    $.ajaxSetup({
    async:false
    });
    

    and then

    function test_func() {
    var temp;
        t=$.post("test.php", { cmd: "testing" })
        return t.responseText;
    }
    

    the answer is only to make your current setup work else there are better ways to deal with it

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

Sidebar

Related Questions

I wish to use the method with the following signature: exec(String command, String[] envp,
I am trying to use jQuery AJAX. What my requirement is, i wish to
I wish use a uisegmentedcontrol in my app with 3 segments but not with
I have a large amount of data I wish to use with Jquery DataTable
We wish to use jquery/javascript to add 'alternate link rss' elements in the section
I wish to use JQuery to replace (backward and forward) <a id=my_id>abc</a> to <span
How can I use jQuery to trigger a callback of a JavaScript function when
I wish to use a jQuery .load(oracle apex url) query. I have a main
I wish to use xml and xsl to generate controls on an asp.net page.
I wish to use the Validating event on a label in VB.Net (Visual Studio

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.