HELP: Slow response in checkbox using javascript and ajax | Newbie | | Join Date: Oct 2009
Posts: 5
| |
Hi everyone. Im trying to optimize a website. But im stuck with this code here. My problem is when i check/uncheck the checkbox it took 5-6 sec just by clicking it. Could anyone help me rewrite this code?. please - function checkAccess(celDiv,id)
-
{
-
var celValue = $(celDiv).html();
-
-
if (celValue==1) $(celDiv).html("<input type='checkbox' value='"+$(celDiv).html()+"' checked disabled>")//display detFlex1
-
else $(celDiv).html("<input type='checkbox' value='"+$(celDiv).html()+"' disabled>")//convert value of checkbox to 0/1
-
-
$(celDiv).click
-
(
-
function()
-
{
-
$('input',this).each(
-
function(){
-
-
tr_idx = $('#detFlex1 tbody tr').index($(this).parent().parent().parent());
-
td_idx = $('#detFlex1 tbody tr:eq('+tr_idx+') td').index($(this).parent().parent());
-
td_last = 13;
-
for(var td=td_idx+1; td<=td_last;td++)
-
{
-
if ($(this).attr('checked') == true)
-
{
-
df[0].rows[tr_idx].cell[td_idx] = 1;//index[1] = Full Access
-
if (td_idx==3)
-
{
-
df[0].rows[tr_idx].cell[td] = 1;
-
}
-
df[0].rows[tr_idx].cell[2] = 1;
-
if (td_idx > 3)
-
{
-
df[0].rows[tr_idx].cell[2] = 1;
-
}
-
}
-
else
-
{
-
df[0].rows[tr_idx].cell[td_idx] = 0;//index[0] = With Access
-
if (td_idx==2)
-
{
-
df[0].rows[tr_idx].cell[td] = 0;
-
}
-
else if (td_idx==3)
-
{
-
df[0].rows[tr_idx].cell[td] = 0;
-
}
-
if (td_idx > 3)
-
{
-
df[0].rows[tr_idx].cell[3] = 0;
-
}
-
}
-
}
-
$('#detFlex1').flexAddData(df[0]);
-
$('.toolbar a[title=Edit Item]').trigger('click');
-
});
-
}
-
);
-
}
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 3,642
| | | re: HELP: Slow response in checkbox using javascript and ajax
do you have a site where I can check that? At first glance I don’t see a cause for such a delay, so I’d use FireBug to check that.
| | Newbie | | Join Date: Oct 2009
Posts: 5
| | | re: HELP: Slow response in checkbox using javascript and ajax
Hi, Dormilich
Thanks for checking the codes. I am also using Firebug. No error is being displayed. I'm suggesting of redoing the javascript code but im still a newbie xD.
This is an open source web app. http://www.comunionerp.com/web/sec_users/login
PS: if you are interested in contributing some codes then please add me in ym: <email_removed>
Thanks
-Dean
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 3,642
| | | re: HELP: Slow response in checkbox using javascript and ajax Quote:
Originally Posted by kikz4life I am also using Firebug. No error is being displayed. I don’t want to check the code for correctness, I want to see if I can find the line that takes so long using the breakpoints.
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 3,642
| | | re: HELP: Slow response in checkbox using javascript and ajax the page responds reasonably well, maybe your connection is too slow? (despite I’m not sure, whether this is the page you’re talking about, since I didn’t find the ids and classes from the code)
| | Newbie | | Join Date: Oct 2009
Posts: 5
| | | re: HELP: Slow response in checkbox using javascript and ajax - $(celDiv).click
-
(
- function()
-
{
-
$('input',this).each(
-
function(){
-
-
var tr_idx = $('#detFlex1 tbody tr').index($(this).parent().parent().parent());
-
var td_idx = $('#detFlex1 tbody tr:eq('+tr_idx+') td').index($(this).parent().parent());
-
var td_last = 13;
-
............
-
});
-
}
-
);
-
}
i'm thinking that the problem is within this code. What do u think.?
Thanks again
-Dean
| | Newbie | | Join Date: Oct 2009
Posts: 5
| | | re: HELP: Slow response in checkbox using javascript and ajax Quote:
Originally Posted by Dormilich the page responds reasonably well, maybe your connection is too slow? (despite I’m not sure, whether this is the page you’re talking about, since I didn’t find the ids and classes from the code) have u tried the site? the problem is not in the the login page. Its in the User Access Level located at the side nav in the main page under Administrator Module. http://www.comunionerp.com/web/sec_accesslevel | | Newbie | | Join Date: Oct 2009
Posts: 5
| | | re: HELP: Slow response in checkbox using javascript and ajax
awts, i cant login. someone change the password of admin again.. X-(.
anyway i have attach a .bmp. this is how it looks like in the page(attached).
|  | Similar JavaScript / Ajax / DHTML bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,376 network members.
|