Just_Johnny Posted March 30, 2009 Share Posted March 30, 2009 I have a lookup system using the prototype.js framework. It works great except it loads very slow. Is there anything I can do about this? ??? Quote Link to comment https://forums.phpfreaks.com/topic/151679-prototypejs-loads-slow-is-there-anything-i-can-do/ Share on other sites More sharing options...
corbin Posted March 30, 2009 Share Posted March 30, 2009 You could find out why it loads slowly. Quote Link to comment https://forums.phpfreaks.com/topic/151679-prototypejs-loads-slow-is-there-anything-i-can-do/#findComment-796541 Share on other sites More sharing options...
Just_Johnny Posted March 30, 2009 Author Share Posted March 30, 2009 1. I login to phpfreaks.net 2. Go to ajax help where I posted a topix requesting help. (YES, I've got a reply!) Then I read what you just posted. "You could find out why it loads slowly." Corbin, nothing personal but please don't reply to anymore of my posts. I'm just simply asking if anybody else has had a similar problem. Quote Link to comment https://forums.phpfreaks.com/topic/151679-prototypejs-loads-slow-is-there-anything-i-can-do/#findComment-796571 Share on other sites More sharing options...
corbin Posted March 30, 2009 Share Posted March 30, 2009 "Is there anything I can do about [it loading very slowly]?" "You could find out why it loads slowly." I was being dead serious. How are we supposed to help you make it load not slowly if we don't know why it loads slowly? Quote Link to comment https://forums.phpfreaks.com/topic/151679-prototypejs-loads-slow-is-there-anything-i-can-do/#findComment-796583 Share on other sites More sharing options...
MadTechie Posted March 30, 2009 Share Posted March 30, 2009 Sorry Just_Johnny, but corbin is correct - Can you give us more info.. for example.. is it due to a long complex sql query.. maybe its looking at a remote server.. is the output very large! does it only run slow when using prototype.js.. i'll stop their but the list can get quite long.. you really need to give more info.. corbin's post was very direct without much detail (just like your first post)! Quote Link to comment https://forums.phpfreaks.com/topic/151679-prototypejs-loads-slow-is-there-anything-i-can-do/#findComment-797229 Share on other sites More sharing options...
Just_Johnny Posted March 31, 2009 Author Share Posted March 31, 2009 <?php $query = "SELECT DISTINCT(make) FROM lookup_table WHERE type IN ('Tuner_GT_Sp') ORDER BY make"; $result = MYSQL_QUERY($query); $count = MYSQL_NUM_ROWS($result); echo MYSQL_ERROR(); $makeArray = array("Choose Make"); for ($x=0; $x<$count; $x++){ $make = MYSQL_RESULT($result, $x, "make"); array_push($makeArray, $make); } mysql_close($dbConnection); ?> <html> <title>Spoiler Chooser</title> <head> <script type="text/javascript" src="prototype.js"></script> <script> function sendRequest() { new Ajax.Request("test2.php", { method: 'post', parameters: 'make='+ $F('make') + 'year='+ $F('year'), onComplete: showResponse }); } function showResponse(req){ $('show').innerHTML= req.responseText; } </script> </head> <body> <form id="name" onsubmit="return false;"> <select name="make" id="make"> <? for($x=0;$x<count($makeArray);$x++){ echo "<option value=\"".$makeArray[$x]."\">".$makeArray[$x]."</option>"; } ?> </select> <br/><br/> <select name="year" id="year"> <option value='Year'>Year</option> <option value='1980'>1980</option> <option value='1981'>1981</option> <option value='1982'>1982</option> <option value='1983'>1983</option> <option value='1984'>1984</option> <option value='1985'>1985</option> <option value='1986'>1986</option> <option value='1987'>1987</option> <option value='1988'>1988</option> <option value='1989'>1989</option> <option value='1990'>1990</option> <option value='1991'>1991</option> <option value='1992'>1992</option> <option value='1993'>1993</option> <option value='1994'>1994</option> <option value='1995'>1995</option> <option value='1996'>1996</option> <option value='1997'>1997</option> <option value='1998'>1998</option> <option value='1999'>1999</option> <option value='2000'>2000</option> <option value='2001'>2001</option> <option value='2002'>2002</option> <option value='2003'>2003</option> <option value='2004'>2004</option> <option value='2005'>2005</option> <option value='2006'>2006</option> <option value='2007'>2007</option> <option value='2008'>2008</option> <option value='2009'>2009</option> </select> <input type="submit" value="Search" onClick="sendRequest()"> </form> <div id="show"></div> <br/><br/> </body> </html> Sorry corbin I didn't mean to take your reply the wrong way. This is my code, it takes about 20 secs to display the select dropdown forms. Quote Link to comment https://forums.phpfreaks.com/topic/151679-prototypejs-loads-slow-is-there-anything-i-can-do/#findComment-797465 Share on other sites More sharing options...
MadTechie Posted March 31, 2009 Share Posted March 31, 2009 I'm off to bed.. so not going to be much help but just 1 thing.. how long does that query take ? as it make a question of just speeding that up.. (of course you could also reduce your script by 1 loop) but i don't think it will make a major impact also is it this page or test2.php thats causing the problems (as i see results are loading from their) Quote Link to comment https://forums.phpfreaks.com/topic/151679-prototypejs-loads-slow-is-there-anything-i-can-do/#findComment-797470 Share on other sites More sharing options...
corbin Posted March 31, 2009 Share Posted March 31, 2009 I'm guessing it's test2.php that's causing the slow load. What is the code there? Quote Link to comment https://forums.phpfreaks.com/topic/151679-prototypejs-loads-slow-is-there-anything-i-can-do/#findComment-797477 Share on other sites More sharing options...
Just_Johnny Posted March 31, 2009 Author Share Posted March 31, 2009 <?php $yearMake = $_POST['make']; $yearMakeArray = explode("year=",$yearMake); $make = $yearMakeArray[0]; $year = $yearMakeArray[1]; $query = "SELECT DISTINCT model,year FROM lookup_table WHERE type IN ('Tuner_GT_Sp') AND make='".$make."'"; $result = MYSQL_QUERY($query); $count = MYSQL_NUM_ROWS($result); echo MYSQL_ERROR(); $model_array = array(); for ($x=0; $x<$count; $x++){ $model = MYSQL_RESULT($result, $x, "model"); $year_string = MYSQL_RESULT($result, $x, "year"); if (format_year($year_string, $year)){ array_push($model_array, $model); } } $model_array_unique = array_unique($model_array); $count = count($model_array_unique); if($count == "0"){ echo "no matches"; }else{ echo '<div style="position:absolute; right:115px; top:100px; width:200px; height:100px; background-color:#FB0303;">'; echo "<font size=2><u>CHOOSE MODEL<br/><br/></u></font>"; for ($x=0; $x<$count; $x++){ echo $model_array_unique[$x]."<br>"; } echo '</div>'; } ?> Here is test2.php. I think I'm going to stop using prototype guys, it's causing me to not know what I'm doing. When I don't know what I'm doing I run here and post stupid questions. Quote Link to comment https://forums.phpfreaks.com/topic/151679-prototypejs-loads-slow-is-there-anything-i-can-do/#findComment-797492 Share on other sites More sharing options...
corbin Posted March 31, 2009 Share Posted March 31, 2009 I'm pretty sure it's the MySQL query that's slowing things down. Try: $start = microtime(true); mysql_query("...."); $end = microtime(true); echo $end - $start; Quote Link to comment https://forums.phpfreaks.com/topic/151679-prototypejs-loads-slow-is-there-anything-i-can-do/#findComment-797497 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.