I have been trying to get web2py to read a post request sent from 
javascript, but without any success. I hope you guys can help figure out 
what is going on. Here is the code:

View:
<script type="text/javascript">

YUI().use("json-stringify", "io", "dump", "json-parse", function(Y) {
    Y.io('data', {
        method: 'POST',
            data: 'test',
            on: {
                success: function(id, o) {
                    var jsonResponse = Y.JSON.parse(o.response)
                        Y.log("RAW JSON DATA: " + o);
                    Y.log("json data: " + o.responseText);
                    Y.log("header:" + jsonResponse.header);
                    Y.log("status:" + o.statusText);
                    Y.log("keys:" + Object.keys(o));
                    Y.log("id:" + id);
                    Y.one("#output").set("text", o.response); 
                },
                failure: function(x, o) {
                    alert("Async call failed!");
                }
            },
            headers: {
                'Content-Type': 'application/json'
            }
        })

});
    -->
</script>

<p>Type something and press the button.
   The last 10 entries will appear sorted in a table below.</p>

<INPUT id="qtr" type="text" name = "q" value="web2py"/>
<button id="readygo">OK</button>

<br/>
<ul id="out">
</ul>

Controller:
@service.json
def data():
if request.vars:
for var in request.vars:
data[var] = []
data[var].append(request.vars[var])
 return data



-- 



Reply via email to