473,398 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Ajax speed problem

Hi All,

Ive been having a problem of late with one of my sites that uses PHP5 / Ajax. The problem is that periodically the ajax functions lock up and it gets stuck in the loading phase of the request. If i restart the apache server everything goes back to normal (i assume it severs the connection to the ajax called function).

I think this is a problem with the javascript part as i have tried it using a straight post request and have have no problems and slow loading time is localized to the one user (ie. still works fine on the other computers on my office network).

I have recorded this happening in Firefox, safari and IE6 & 7

My server is running debian with apache2 and php5

Just wondering if somebody can shed some light on what my problem may be?


Cheers

Will
Oct 15 '07 #1
2 1723
dmjpro
2,476 2GB
Hi All,

Ive been having a problem of late with one of my sites that uses PHP5 / Ajax. The problem is that periodically the ajax functions lock up and it gets stuck in the loading phase of the request. If i restart the apache server everything goes back to normal (i assume it severs the connection to the ajax called function).

I think this is a problem with the javascript part as i have tried it using a straight post request and have have no problems and slow loading time is localized to the one user (ie. still works fine on the other computers on my office network).

I have recorded this happening in Firefox, safari and IE6 & 7

My server is running debian with apache2 and php5

Just wondering if somebody can shed some light on what my problem may be?


Cheers

Will
Ok post your codes here with Code Tags.
And let us know it.

Debasis Jana
Oct 15 '07 #2
Ok post your codes here with Code Tags.
And let us know it.

Debasis Jana
Hi,

Here is my main ajax function

Cheers

Will


Expand|Select|Wrap|Line Numbers
  1.  
  2. function submitFormCustom(f, field1, field2, dable){     
  3.     // disable form, or not
  4.     disable = true;
  5.     lastform = f;
  6.     if (disable === true) {
  7.         disable_form(f, true);
  8.     }
  9.  
  10.     // re-id eval ajax part
  11.     if (document.getElementById('ajxjs')) {    
  12.         document.getElementById('ajxjs').innerHTML = '';
  13.         document.getElementById('ajxjs').id = 'id_'+Math.random();
  14.     }
  15.  
  16.  
  17.     if(window.XMLHttpRequest){ 
  18.         var xmlReq = new XMLHttpRequest(); 
  19.  
  20.         if (xmlReq.overrideMimeType) {
  21.             //set type accordingly to anticipated content type
  22.             //http_request.overrideMimeType('text/xml');
  23.             xmlReq.overrideMimeType('text/html');
  24.         }
  25.     } else if(window.ActiveXObject) { 
  26.  
  27.         try {
  28.             var xmlReq = new ActiveXObject("Msxml2.XMLHTTP");
  29.         } catch (e) {
  30.             try {
  31.                 var xmlReq = new ActiveXObject("Microsoft.XMLHTTP");
  32.             } catch (e) {}        
  33.         }
  34.     } 
  35.  
  36.     var formData = '', elem = ''; 
  37.     for(var s=0; s<f.elements.length; s++){ 
  38.         elem = f.elements[s]; 
  39.         if ((elem.type == 'checkbox' || elem.type == 'radio') && elem.checked == false) {
  40.             continue;
  41.         }
  42.  
  43.         var selemval = '';
  44.  
  45.         if (elem.tagName == 'SELECT' && elem.multiple === true) {
  46.             var selem = elem.getElementsByTagName('option');
  47.             for (i = 0; i < selem.length; i++) {
  48.                 selemval = '';
  49.                 if (selem[i].value != "" && selem[i].selected === true) {
  50.                     if(formData != ''){ 
  51.                         formData += '&'; 
  52.                     } 
  53.                     selemval = selem[i].value; 
  54.                     formData += elem.name+"="+selemval.replace(/&/g, 'amp;'); 
  55.                 }
  56.             }
  57.         } else {
  58.             if(formData != ''){ 
  59.                 formData += '&'; 
  60.             } 
  61.             selemval = elem.value;
  62.             formData += elem.name+"="+selemval.replace(/&/g, 'amp;');
  63.         }
  64.     } 
  65.  
  66.     if (formData != "") {
  67.         formData += "&xrand="+randomString(8);
  68.     }
  69.  
  70.  
  71.  
  72.     xmlReq.onreadystatechange = function(){ 
  73.         if(xmlReq.readyState == 4){ 
  74.  
  75.             if (content = xmlReq.responseText) {
  76.  
  77.                 if (trim_str(content) != "") {
  78.                     try {
  79.                         document.getElementById(field1).innerHTML = content;
  80.                     }
  81.                     catch (e) {
  82.                         alert(document.getElementById(field1).innerHTML);
  83.                     }
  84.                     // evaluate JSON
  85.                     if (document.getElementById('jsonjs')) {
  86.                         try {
  87.                             var json = eval("(" + document.getElementById('jsonjs').innerHTML + ")");    
  88.                         } catch (e) {
  89.                             alert('Could not evaluate JSON '+e);
  90.                         }
  91.                     } // end eval JSON
  92.                     // evaluate regular JS
  93.                     if (document.getElementById('ajxjs')) {
  94.                         try {
  95.                             eval(document.getElementById('ajxjs').innerHTML);    
  96.                         }
  97.                         catch (e) {
  98.                             alert('Could not evaluate javascript '+e);
  99.                         }
  100.                     } // end eval js
  101.                     if (disable === true) {
  102.  
  103.                         if (!document.getElementById('msgdivarea') && !document.getElementById('cbform')) {
  104.                             disable_form(f, false);
  105.                         }
  106.  
  107.                         if (resetform === true){
  108.                             f.reset();
  109.                         }
  110.                     }
  111.                 }
  112.             }
  113.             document.getElementById(field2).innerHTML = "";
  114.             blockoff = false;
  115.         } else if (xmlReq.readyState == 1) {
  116.             document.getElementById(field2).innerHTML = '<span class="ld">Loading ...</span>';
  117.         } else if (xmlReq.readyState == 3) {
  118.             document.getElementById(field2).innerHTML = '<span class="ld">Please wait ...</span>';
  119.         } else if (xmlReq.readyState == 2) {
  120.             document.getElementById(field2).innerHTML = "";
  121.         }
  122.     }
  123.     xmlReq.open(f.method, f.action, true);
  124.     xmlReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  125.     xmlReq.setRequestHeader("Content-length", formData.length);
  126.     xmlReq.setRequestHeader("Connection", "close");
  127.     xmlReq.send(formData); 
  128.     return false; 
  129.  
  130. }
  131.  
Oct 15 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: G Matthew J | last post by:
interesting "signal vs. noise" blog entry: http://37signals.com/svn/archives2/whats_wrong_with_ajax.php
4
by: Gaffar | last post by:
Hello. My name is Gaffar. I am handling an module in a Project. This application interface is slow and inefficient. So Client told "implement an AJAX Solution which will increase speed and...
1
by: John Chan | last post by:
Hi, Im doing a maintenance application in ajax and coldfusion at work on IE6 exclusively. I have a save button on each form and i have to do various validations server side and on client side...
3
by: BG Mahesh | last post by:
hi We are looking for a good Ajax library which has very good support for iframe. The ones we have considered so far are, Backbase.com - not happy with the speed Zapatech.com - it is good but...
13
by: =?Utf-8?B?Y2hpeDIz?= | last post by:
Hi!!! I am having a hard time processing 20,000 records using AJAX. AJAX threw an internet connection timeout. Is there any way that I can increase the internet connection timeout by using...
8
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post by:
I'm about to finally make the jump and start a new site using AJAX. THe question i have for all of you AJAX developers out there is which one? 1. The Standard AJAX frame work 2. The Tool kit....
3
by: willl69 | last post by:
Hi All, Ive been having a problem of late with one of my sites that uses PHP5 / Ajax. The problem is that periodically the ajax functions lock up and it gets stuck in the loading phase of the...
3
by: NetWave | last post by:
Hi, For my next project I'm going to need Ajax, so I'm in about to read some books on ASP.NET Ajax. While reading Rick Strahl's blog I stumbled upon jQuery. I've been to the website and seen...
8
by: Tomasz J | last post by:
Hello developers, After migrating my web project application (using the old model) to .Net Framework 3.5 and Ajax Control Toolkit release 20820 the Accordion control no longer works correctly....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.