Hi,
I am using Trac-1.0.15 and I am using an ajax request to get a small
piece of data from server. I use ajax 'GET' method.
var all_data = {'opp_details':true, 'opp_id':$(this).val()};
$.ajax({
type:'GET',
//url:prefix+'/SalesProposalReport/',
url:'SalesProposalReport/',
data:all_data,
success:function(){
console.log("Ajax_over!");
},
});
Server side code in web_ui.py file,
# Special case for ajax
if ((path == "/SalesProposalReport/") and (req.method == 'GET')):
details =
self.get_opp_details(req.args.get('opp_id'))
data = {'message':'success', 'details':details}
self.respond(req, data)
the get_opp_details method is
def get_opp_details(self, opp_id):
with self.env.db_transaction as db:
cursor = db.cursor()
dtls_query = "select oppname from opportunity where
oppid='%s'"%(opp_id)
cursor.execute(dtls_query)
dtls = cursor.fetchall()
desc = cursor.description
if not desc:
return []
details = {}
if dtls:
for item in dtls:
for field, col in zip(item, desc):
details[col[0]] = str(field)
return details
And the respond method is
def respond(self, req, data, code=200):
json_data = json.dumps(data)
req.send_response(code)
req.send_header('Content-Type','application/json')
req.send_header('Content-Length',len(json_data))
req.write(json_data)
raise RequestDone
Any guess why my ajax is very slow? it takes 11 sec everytime to load a
single piece of data from server. How can I reduce this? Please help me.
--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/d55222b9-ab65-43b0-bf5a-4ce7b16d1deeo%40googlegroups.com.
I am using Trac-1.0.15 and I am using an ajax request to get a small
piece of data from server. I use ajax 'GET' method.
var all_data = {'opp_details':true, 'opp_id':$(this).val()};
$.ajax({
type:'GET',
//url:prefix+'/SalesProposalReport/',
url:'SalesProposalReport/',
data:all_data,
success:function(){
console.log("Ajax_over!");
},
});
Server side code in web_ui.py file,
# Special case for ajax
if ((path == "/SalesProposalReport/") and (req.method == 'GET')):
details =
self.get_opp_details(req.args.get('opp_id'))
data = {'message':'success', 'details':details}
self.respond(req, data)
the get_opp_details method is
def get_opp_details(self, opp_id):
with self.env.db_transaction as db:
cursor = db.cursor()
dtls_query = "select oppname from opportunity where
oppid='%s'"%(opp_id)
cursor.execute(dtls_query)
dtls = cursor.fetchall()
desc = cursor.description
if not desc:
return []
details = {}
if dtls:
for item in dtls:
for field, col in zip(item, desc):
details[col[0]] = str(field)
return details
And the respond method is
def respond(self, req, data, code=200):
json_data = json.dumps(data)
req.send_response(code)
req.send_header('Content-Type','application/json')
req.send_header('Content-Length',len(json_data))
req.write(json_data)
raise RequestDone
Any guess why my ajax is very slow? it takes 11 sec everytime to load a
single piece of data from server. How can I reduce this? Please help me.
--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/d55222b9-ab65-43b0-bf5a-4ce7b16d1deeo%40googlegroups.com.