On 26 Nov 2013, at 4:33 AM, Yebach <[email protected]> wrote:

> I menage to call my function that is in my default.py controler  from my view 
> but I cannot  retrieve data that this function is suppose to retrieve
> 
> function is called on button click to load some text from database into ACE 
> editor 
> 
> this is some of my code in controler.py 
> 
> def load_last():
>     PgSQL = db_conn()
>     cur = PgSQL.cursor()
>     sql_read = "SELECT file_text FROM datoteke WHERE id = (SELECT max(id) 
> FROM datoteke)"
>     cur.execute(sql_read)
>     ver = cur.fetchone()[0]
>     print ver
>     
>     return dict(data = ver)
> 
> in my editor.html view my java script code that should get data from def 
> load_last functions is
> 
> function load_last() {
>          var editor = ace.edit("editor");
>          editor.setValue("");
>          $.ajax({
>                  url: "{{=URL('default', 'load_last')}}",
>                  data: {}, //WHAT DO I WRITE HERE
>                  success: function(){
>                          console.log("neki je ratal");
>                  },
>                  dataType: 'html'
>                });
>               }
> 
> 
> I am really stuck here
> 

Put the common code in your model, or in a module.

-- 
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.

Reply via email to