Hello,
I have a very basic question about the use of the :eval argument for the
ajax().
I am running a very basic test case where I have the following code in my
view:
<script>
$( document ).ready(function() {
ajax('fetch', [], ':eval');
});
document.write(data);
</script>
with the following code in a controller:
def fetch():
## fetch var from here when called by the view using AJAX
test = "Test String Fetched"
result = "var data = %s;" % test
return result
What I would like to happen, is when the document finishes loading, it will
call the fetch function in the given controller, and return the "result"
string which will be evaluated as a javascript variable that I can then
further use in the view. However, when I run this as is, it tells me that I
have an "Uncaught ReferenceError: data is not defined". Digging a bit
further, I noticed I also get an "Uncaught SyntaxError: Unexpected token < "in
the Javascript Console. Any help or a point in the right direction would
be helpful, I've dug through the book without much further success.
Cheers,
Lyndon
--
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/groups/opt_out.