title: How to set up AJAX path to SimpleHTTP server using GET
body: <p>I have a string that is stored in a variable, request_str, and I want to pass that data to a SimpleHTTP python web server. I am unsure how to go about actually connecting the AJAX that I have to the simpleHTTP server. </p>
  
  <p>Here is the ajax I've set up so far</p>
  
  <pre><code>$.ajax({
          url: "SOMEPLACE",
          data: {
              "key": request_str.toUpperCase()
          }
      });
  </code></pre>
  
  <p>Here is the python code for the SimpleHTTP server I'm using. </p>
  
  <pre><code>"""
  Serves files out of its current directory
  Dosen't handle POST request
  """
  
  import SocketServer
  import SimpleHTTPServer
  
  PORT = 9090
  
  def move():
      """ sample function to be called via a URL"""
      return 'hi'
  
  class CustomHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
      def do_GET(self):
          #Sample values in self for URL: http://localhost:9090/jsxmlrpc-0.3/
          #self.path  '/jsxmlrpc-0.3/'
          #self.raw_requestline   'GET /jsxmlrpc-0.3/ HTTP/1.1rn'
          #self.client_address    ('127.0.0.1', 3727)
          if self.path=='/move':
              #This URL will trigger our sample function and send what it returns back to the browser
              self.send_response(200)
              self.send_header('Content-type','text/html')
              self.end_headers()
              self.wfile.write(move()) #call sample function here
              return
          else:
              #serve files, and directory listings by following self.path from
              #current working directory
              SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
  
  httpd = SocketServer.ThreadingTCPServer(('localhost', PORT),CustomHandler)
  
  print "serving at port", PORT
  httpd.serve_forever()
  </code></pre>
  
  <p>The reason I ask how to set it up using GET, is because the way the server is set up. I am open to suggestions, and changing it to POST, if I can get a clear explanation. Someone told me I should json the data, but I'm not sure what that means. </p>
  
  <p>Looking forward to the help! </p>