473,654 Members | 3,108 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Ajax speed problem

2 New Member
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 1744
dmjpro
2,476 Top Contributor
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
willl69
2 New Member
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
2056
by: G Matthew J | last post by:
interesting "signal vs. noise" blog entry: http://37signals.com/svn/archives2/whats_wrong_with_ajax.php
4
1558
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 efficiency and user's experience". So, My problem is what is AJAX Solution. How to implement that. what are the feataures. Please give with a sample solution. Thanx in advance. Regards Gaffar.
1
1935
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 when the user clicks save i.e check that user exists in table, check users password is the same as password in table, check password is valid, check that logged in user is a super user etc etc to get the correct error message. Different forms may or...
3
2769
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 doesn't have support for iframe openreco.org - it is good but doesn't support iframe Any pointers is appreciated. We are doing the development on Linux.
13
3018
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 web.config? I am using ASP.NET 1.1. Thanks!!!
8
1698
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. Or are there others out there. 4. Should i not do AJAX at all because it still posts back the entire page even though only the section is refreshed. (someone tell me i'm wrong here and why please!)
3
2469
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 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...
3
2400
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 some examples, and it sure looks promising. However, I'm not sure how it relates to ASP.NET Ajax. Do they complement each other? Or are they concurrent products?
8
2725
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. In certain cases (only) it renders but is dead - does not initialize. Before the migration it worked, no changes have been made. Here is the complete scenario description:
0
8376
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8815
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8708
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8489
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7307
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6161
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2716
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.