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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:11:53+00:00 2026-05-25T01:11:53+00:00

Apologies up front for the noob question… Hello, how do I get data from

  • 0

Apologies up front for the noob question…

Hello, how do I get data from the Python end of an appengine server using jQuery.ajax? I know how to send data to the server using ajax and an appropriate handler, but I was wondering if someone could tell me what the ajax request for getting values from the server looks like. (Suppose I wanted to get a number from the datastore and use it in the javascript).

client sending to server (using jquery)

client-side javascript:

//jQuery and ajax function loaded.

<script type="text/javascript">
    var data = {"salary":500};
    $.ajax({
    type: "POST",
    url: "/resultshandler",
    data: data
</script>

server-side:

class ResultsHandler(webapp.RequestHandler):
    def get(self):
        n = cgi.escape(self.request.get('salary'))
        e = Engineer(salary = n)
        e.put()

and under def main():, I have the handler (‘/put_in_datastore’, ResultsHandler)

Again, what would be the similar code for retrieving numbers from the Python end? If someone could provide both the handler code and javascript code that would be great…

  • 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-25T01:11:53+00:00Added an answer on May 25, 2026 at 1:11 am

    The mechanism is exactly the same either way the data is flowing. Use the success parameter on the ajax call to operate on the data after the request successfully finishes. This is generally called a callback. Other callbacks exist. See http://api.jquery.com/jQuery.ajax/ for the complete information.

    $.ajax({
      url: "/resultshandler",
      type: 'POST',
      data: data,
      success: function(data, status){
        //check status
        //do something with data
      }
    });
    

    On the Python end, you return data with self.response.write.out(output). See example below.

    class ResultsHandler(webapp.RequestHandler):
        def post(self):
            k = db.Key.from_path('Engineer', the_engineer_id) #will be an integer
            e = db.get(k)
            output = {'salary': e.salary}
            output = json.dumps(output) #json encoding
            self.response.write.out(output)
    

    Also, your url routing should look like ('/resultshandler', ResultsHandler). I don’t know where /put_in_datastore came from.

    Finally, notice the def post rather than def get because I’m making a POST request with the Javascript. You could do the same as a GET request, and in that case you’d use def get.

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

Sidebar

Related Questions

Apologies up front, because this isn't a question but a solution - but it
Apologies for the long post, but I wonder if I could get some more
Apologies in advance for the long-winded question. I'm really a database programmer, but have
Apologies if I get the terminology wrong. How do I define a constraint in
Good morning, Apologies for the newbie question. I'm just getting started with ASP.NET internationalization
I am just checking out F#, so apologies if this is a silly question,
WARNING: I have been learning Python for all of 10 minutes so apologies for
We're on the mid-tier DV Rage server on media temple using Zend Framework, and
In trying to get up to speed with C++ (coming from a long experience
Apologies for the title, I found it hard to define my question succintly and

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.