1

I have this simple test AJAX request that sends data to a python script.

$.ajax({
              url: 'parser.py',
              type: 'POST',
              data: {test:"test"},
              dataType: "text",
              success: function(result)
              {
                console.log(result)
              },
              error: function(request, status, error)
              {
                console.log("oops")
              }
            })

I know it's quite simple, but how do I access the posted content that I send to the python script? Is it sent in a query string like PHP?

5
  • It depends on how your python script is executed. Usually people use WSGI-based frameworks in python which then provide GET and POST values in a framework-specific way. Commented Apr 19, 2012 at 17:04
  • This question has no answer unless you say how you're running that script. Commented Apr 19, 2012 at 17:04
  • I have gotten the results I wanted when using a test GET request to the python script, opening the URL to the API with urllib2, reading the XML and then parsing it. I wasn't completely aware I needed something additional for POST requests. Commented Apr 19, 2012 at 17:08
  • possible duplicate of Passing JSON from jQuery .getJSON to Python Commented Apr 19, 2012 at 17:12
  • This question helped solve mine: [Passing JSON from jQuery .getJSON to Python][1] [1]: stackoverflow.com/questions/10232327/… Commented Jul 17, 2012 at 20:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.