Hello

I have a db insert statement in my controller code. After user inserts 
text, clicks save it is saved into database, but the javascript part of the 
code returns error. This only occurs if page is accessed from another 
computer.If I run it from localhost of the server no error is returned

Any ideas?

here is my code

the controller in default.py


def add_item():
    
    acedata =  request.body.read()
    data = gluon.contrib.simplejson.loads(acedata)
    ace_script =  str(data["podatki"])
    #print ace_script
    #print "tukej"
    PgSQL = db_conn() ##
    cur = PgSQL.cursor()
    print cur
    
    sql = """
            INSERT INTO datoteke(
                    file_name, file_text)
            VALUES ('%s', '%s');""" % ('neki', ace_script)
    #print sql
    cur.execute(sql)        
    PgSQL.commit()
    PgSQL.close()
    print "DONE!!!"
    return dict()

and my js part

 function add_item(url, item_id, some_detail) {
  var test = saveContent();
  var dat = {'podatki' : test};
  console.log(dat);
  var data = JSON.stringify(dat);
  console.log(url);
  doPost("{{=URL('default', 'add_item')}}", data);
  
 }

function doPost(callback, data) {
  $.post(callback, data, function(data){})
  .done(function() { alert("Done!"); })
  .fail(function() { alert("Failed!");})
 }



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