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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:32:51+00:00 2026-06-09T01:32:51+00:00

I recently tried implementing the SimpleHTTPRequestHandler to accept AJAX requests according to this .

  • 0

I recently tried implementing the SimpleHTTPRequestHandler to accept AJAX requests according to this.

Although everything seems to work as far as receiving the request from the client, I cannot send anything back to the client, when I try to self.wfile.write(“foo”), I get a response back in the client; however, the response text from the XmlObject is completely blank!?!

If anybody can shed any light on this, that would be great!

EDIT: I think my AJAX call is structured correctly since I am getting responses from Python (I’ve checked in debug mode); however, I am not getting any message back responseText when I get an object back.

  • 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-09T01:32:52+00:00Added an answer on June 9, 2026 at 1:32 am

    Make sure your response has a send_header() with a content type. I have seen AJAX requests get confused without this. You can also try switching your POST to a GET for debugging and make sure the browser can see the content.

    Here is a simple HTTP example for returning XML if you point your query or browser to 127.0.0.1/test:

    import SimpleHTTPServer, SocketServer
    import urlparse
    
    PORT = 80
    
    class MyHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
       def do_GET(self):
    
           # Parse query data & params to find out what was passed
           parsedParams = urlparse.urlparse(self.path)
           queryParsed = urlparse.parse_qs(parsedParams.query)
    
           # request is either for a file to be served up or our test
           if parsedParams.path == "/test":
              self.processMyRequest(queryParsed)
           else:
              # Default to serve up a local file 
              SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self);
    
       def processMyRequest(self, query):
    
           self.send_response(200)
           self.send_header('Content-Type', 'application/xml')
           self.end_headers()
    
           self.wfile.write("<?xml version='1.0'?>");
           self.wfile.write("<sample>Some XML</sample>");
           self.wfile.close();
    
    Handler = MyHandler
    
    httpd = SocketServer.TCPServer(("", PORT), Handler)
    
    print "serving at port", PORT
    httpd.serve_forever()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently tried to pull some results and was struggling to work out the
Recently I tried compiling program something like this with GCC: int f(int i){ if(i<0){
I recently tried a lot of different stuff with lightweight migration. These all work:
I recently tried to create an object like this: var carousel = { $slider:
As a learning experience I recently tried implementing Quicksort with 3 way partitioning in
I recently tried to work out how the solution to a ThreadPool class works
I've recently tried using branches in git but while they work allright whatever I
I recently tried to do something akin to this: a = some string b
I've recently tried operator overloading, and have looked at this stackoverflow page (http://stackoverflow.com/questions/4421706/operator-overloading) about
Recently tried the plugin example of Qt. It didn't work at all and I

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.