I'm getting a strange behavior with ajax call. I can print the
request.post_vars andd see they are there but when I try to access them,
they are None.
And it was working fine until I added extra data into FormData. I've
removed the new data (back to when it was working) but it doesn't work
anymore.
This isn't the first time I ran into this. Seems to happen when I add new
data varas to the already working ajax calls. They usually go away when I
revert back.
[view]
function uploader(event) {
var form_data = new FormData();
var file = event.target.files[0];
form_data.append('uploading', file, file.name);
//form_data.append('category', 'summary'); /* this is the new bit added
that started causing problem - removed but no change */
$.ajax({
url: '{{=URL("upload_file")}}',
type: 'POST',
data: form_data,
cache: false,
processData: false,
contentType: false,
}).done(function(data) {/* do stuff */});
}
[controller]
def upload_file():
print 'vars', request.post_vars # shows vars passed properly
# error here <type 'exceptions.AttributeError'> 'NoneType' object has
no attribute 'file'
upload_file = request.post_vars.uploading.file
--
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.