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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:21:57+00:00 2026-05-29T06:21:57+00:00

I have a serverside function: string foo(string input_string); for example: foo(bar) returns baz and

  • 0

I have a serverside function:

string foo(string input_string);

for example:

foo("bar") returns "baz"

and have wrapped this function into a HTTP server such that:

POST /foo HTTP/1.1
...

bar

will return:

HTTP/1.1 200 OK
...

baz

ie a POST request with the input string as the HTTP Message Body will return the output string as the HTTP Message Body of the 200 OK.

Now in my javascript on the web page I have two functions:

function sendFoo(input_string)
{
   ??? // should asynchronously start process to POST input_string to server
}

function recvFoo(output_string)
{
   ...
}

When I call sendFoo I would like the POST to be made asynchronously to the server and later when the response is received I would like recvFoo called (perhaps in another thread or whatever) with the Message Body of the 200 OK.

How do I implement sendFoo above? I am currently using jQuery, but a solution in pure javascript is ok too. (I can also modify the server if need be?)

Solution:

function sendFoo(input_string)
{
   $.ajax({ url: "/foo", type: "POST", data: input_string, success: recvFoo });
}
  • 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-29T06:21:58+00:00Added an answer on May 29, 2026 at 6:21 am

    No need to fallback to classic JavaScript

    $.ajax({
            url:"URL of foo...",
            type: "POST",
            data: "what ever",
            success: recvFoo
           });
    

    Or the post option:

      $.post('The url of foo', {input_string : 'bar'}, recvFoo);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a server side Python script that returns a JSON string containing parameters
I have a class at server-side like this: public class Address { public Address(string
I have done a bit of testing on this myself (During the server side
Let's say I have a function that takes a string. That string contains the
i have some functionality i'd like to get from the server-side code into the
I am using this plugin: http://jquery.bassistance.de/autocomplete/demo/ I have an autocomplete textarea where the values
I have this client-side: $(document).ready(function() { var $checkboxes = $('[type=checkbox]'); $checkboxes.click(function() { $checkbox =
i have this code on the server side: <?php header('Content-Type: text/html; charset=utf-8'); require ../general.variables.php;
I have made an AJAX function with jQuery. The function works properly, and server
Given I have: $(a.clickable).livequery('click', (function (e) { var values = $(this).attr('id').split('_'); $('#' + values[3]).load($(this).attr('href'));

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.