Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Regular Coder
    Join Date
    Nov 2005
    Thanked 0 Times in 0 Posts

    Multiple http request and show out the loading msg to user.

    Dear all,

    I had function that use AJAX to validate data with database. The problem is, how can i create multiple AJAX request to server and show the status to user?

    current in my coding i cant get back the result and show if i run my application in internet but not problem with same local network & localhost. (this was depend on network traffic)

    for example:
    call function 1 then tell user current run function 1
    call function 2 then tell user current run function 2
    n etc......

    my code:
    //for display loading status
    var BatchQueue = new function(){
    	var functions = new Array();
    	this.add = function(){
    		var object = arguments[0];
    		var actualArguments = new Array();
    		for(var i = 1; i < arguments.length; i++)
    			functions.push({object:object, arguments:actualArguments});
    	this.next = function(){
    		if(functions.length > 0){
    			var nextFunction = functions.shift();
    			nextFunction.object.apply(null, nextFunction.arguments);
    			setTimeout("BatchQueue.next()", 500);
    	this.start = function(){
    		setTimeout("BatchQueue.next()", 0);

    for(i = 1; i <= totalCountRecord; ++i){
    	BatchQueue.add(checkOutStanding, i);
    	BatchQueue.add(chkFrt, i);
    	BatchQueue.add(validateDateInput, i);
    BatchQueue.add(finalSubmitData, i);

    function checkOutStanding(num){
    	xmlHttp = createXmlHttpRequestObject();
    	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0){
    		var values = new Object();
    		values.idValue = eval("document.iframeShow.tempForm.compDetailId_"+num+".value");
    		values.type = 11;
    		values.getValue =  eval("document.iframeShow.tempForm.qty_"+num+".value");
    		document.getElementById("currentRow").value = num;
    		// Encode POST data
    		var data = '';
    		for (var i in values) {
    			data += (data?'&':'')+i+'='+encodeURIComponent(values[i]); 
    		url = "inc/queryForAJAX2.php";
    		xmlHttp.open("POST", url, true);
    		xmlHttp.setRequestHeader ('Content-Type','application/x-www-form-urlencoded;charset=UTF-8');
    		// define the method to handle server responses
    		xmlHttp.onreadystatechange = handleServerResponseForCheckOutStanding;
    		// make the server request
    		// if the connection is busy, try again after one second
    		globalTimeOutId = setTimeout("checkOutStanding("+num+")", 1000);

    or can anyone guide me to create a validate input box with value in database and show out to user current which input box was checking?

    Last edited by CstAn; 06-27-2007 at 02:40 AM.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts