Hi,
it's very simple but I cannot find the mistake. I am tryint to pass a json
from browser to controller with ajas. The result is that the data object in
the script is empty:
The view:
{{extend 'layout.html'}}
<h2>Template default/test2.html</h2>
{{=BEAUTIFY(response._vars)}}
<script>
$(document).ready(function(){
$.ajax({
type: 'POST',
url:'http://127.0.0.1:8000/MFREG/default/test2.json',
contentType: "application/json; charset=utf-8",
data: {'key':'value','key2':'value2'},
dataType: 'json',
success: function(data){ alert("Data: "+ data); }
});
});
</script>
The controller:
def test2():
datos = str(request.vars)
datos2= request.args(0)
return locals()
The result:
<https://lh3.googleusercontent.com/-5ioc1l3lC2A/VJA4HH8GWuI/AAAAAAAAAqY/-2WZfxQxMWg/s1600/Selecci%C3%B3n_804.png>
It's silly but I can't find what is wrong.
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.