0

I can't find any tutorial for jQuery + web.py. So I've got basic question on POST method.

I've got jQuery script:

<script>
     jQuery('#continue').click(function() {
         var command = jQuery('#continue').attr('value');
         jQuery.ajax({
              type: "POST",
              data: {signal : command},
         });
     });
</script>

A simple form:

<form>
    <button type="submit">Cancel</button>
    <button type="submit" id="continue" value="next">Continue</button>
</form>

and python script:

def POST (self):
        s = signal
        print s
        return

I expect to see string "next" in console. But it doesn't happen.

I have a strong feeling that selectors somehow do not work. Any way to check it?

1
  • 3
    jQuery.ajax expects an url to post/get the content, so add the url param next to type and data Commented Dec 6, 2011 at 11:44

2 Answers 2

4

you need to use web.input in web.py to access POST variables

look at the docs: http://webpy.org/docs/0.3/api (search for "function input")

def POST(self):
    s = web.input().signal
    print s
    return
Sign up to request clarification or add additional context in comments.

Comments

0
<script>
     jQuery('#continue').click(function() {
         var command = jQuery('#continue').attr('value');
         jQuery.ajax({
              type: "POST",
              data: {signal : command},
              url: "add the url here"
         });
     });
</script>

add the url of the server.

2 Comments

found this example: kooneiform.wordpress.com/2010/02/28/… - it works without URL.
As I understood from jQuery docs - current page is a default setting for URL, so I can ignore this line

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.