PHP Classes

AJAX Problem

Recommend this page to a friend!

      Top level forums  >  PHP Specialists  >  General  >  AJAX Problem  
Subject:AJAX Problem
Summary:Time consumption is more with ajax
Messages:4
Author:siddharth kulkarni
Date:2008-05-04 08:55:44
Update:2008-08-22 00:07:44
 

  1. AJAX Problem   Reply   Report abuse  
Picture of siddharth kulkarni siddharth kulkarni - 2008-05-04 08:55:44
I have used ajax function for populating two drop down. the values of second drop down depends on the first one. If the retrieved data is large in number the drop down doesn't get refreshed and the browser doesn't respond for a long time.
I have used InitXMLHttpRequest() object for this purpose.
the script used is as follows,
<!--
var req = null;

function InitXMLHttpRequest() {
// Make a new XMLHttp object
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
}
function getval(str,cond1,cond2,cond3,cond4,cond5) {
//document.forms[0].txtsearch.value = document.forms[0].sub_group.text+" "+document.forms[0].item_grp.value
InitXMLHttpRequest();
// Load the result from the response page
if (req) {
req.onreadystatechange = function() {
if (req.readyState == 4) {
document.getElementById("result").innerHTML = req.responseText;
} else {
document.getElementById("result").innerHTML = "Loading data...";
}
}
req.open("GET", "grid2.php?itemname=" + str +"&itemgrp=" + cond1+"&subgroup=" + cond2+"&category=" + cond3+"&cust_code=" + cond4+"&item_lst=" + cond5, true);
req.send(null);
} else {
document.getElementById("result").innerHTML = 'Browser unable to create XMLHttp Object';
}
}
-->

Please suggest changes, if possible, in above code so that i can reduce the time span required for retrieving the data.

There are 3 replies in this thread, which are not being displayed.
Browsing this forum thread replies is available only to premium subscribers.


Go to the premium subscriptions page to learn how to become a premium subscriber and have full access to this forum.