/    Sign up×
Community /Pin to ProfileBookmark

PHP with jQuery performance problem

Has anyone experienced problems with web applications running slow when they are called by JQuery? I will summarise the structure of my application in a sec, but in this case the application hangs in an inconsistent and unpredictable manner as if the webserver runs out of memory (but it is a dedicated webserver) or there are too many database connections or something. OK, here is the structure (I’ll tell you more afterwards):

// .js (javascript file). Bind function
// actionOptAdd to a submit button using jquery
//
$(“.actionOptAdd”).bind(“click”,
function()
{
.
.
.
.
$.getJSON(‘lib/addToProj.php’,
{
.
.
.
.
}, function(data)
{
.
.
$.each(data, function(i,item)
{
//deal with data
}
// write to the HTML some status
message
}
}
// Here’s the HTML with php code where the above actionOptAdd is
associated with the clicking of a button:
<span id=”Add_<?php print $i; ?>” class=”actionOptAdd”> <input
type=”button” name=”btnOk_AddToProject_
<?php print $i; ?>”
class=”button-click-grey” value=”Add to Project” /><span>

//And here’s the outline of php code for addToProj.php…………….

<?php
include_once(“configFiles.php”);
$json_array = array(…..
// do some database transactions.
// code here is not important for the problem I am describing
echo json_encode($json_array); // the .each loop in the jQuery can then analyse the output
// end——————

The PHP/HTML actually binds the addtoproj (via the jQuery) to 10 or more buttons on the page (in a PHP loop, so the same code is involved but the data varies). The user can click on each button in turn to save to the database (that’s what addtoproj does), but sometimes (but far too often) the addtoproj hangs, right at the beginning of the function before having the chance to do anything, even if the previous addtoproj invocations have completed (I can see all this via firephp). Its not stuck in a loop, not busy saving anything to the database, not apparently doing anything except hanging at the very beginning of addtoproj, just after the lines necessary to enable firephp.

In the firephp console you see something like….

-GET http://www.<domain>/app/lib/addtoproj.php?<arguments here>

… and the curly thing rotating at the end of the line indicating that its waiting. Eventually it does come back.

So, actually it is the GET that hangs. Can I remind you that usually a few GETs (on clicking on the button to which the function actionOptAdd is bound) work fine, and then suddenly a GET hangs. Perhaps there are some key PHP variables I need to adjust in the PHPini file? I’ve already increased memory_limit a couple of times (currently set to -1 for no memory limit).

Sorry about the long description but I wanted to give as much detail as possible.

All help will be very much appreciated.

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @Fusioneer spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.26,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...