www.webdeveloper.com
Results 1 to 2 of 2

Thread: AJAX synchronous - problem !!!

Hybrid View

  1. #1
    Join Date
    Oct 2006
    Posts
    26

    Exclamation AJAX synchronous - problem !!!

    hi,

    what I want to do is this: when the page is loaded, I'm calling some JS function, who is using prototype class, and make an ajax request, to some php file, in that file..I'm updating some stuffs in the database. This is taking some time..there is alot of records, so..what I'm trying to do..is showing in Real time, each record..that was updated. so I've made a second function. The problem is that, he is finishing the execution of the first file..and after that his displaying each record updated..and the DONE text. I need him to do this in the same time.

    If anyone can help me please, I've tried many thinks..and couldn't make it.

    I'm sending the functions I'm using..to make an idea :


    Code:
    	function UpdateAgenda(state,county)
    	{
    		if (county!="" && state!="")
    		{
    			var url="my_file.php";
    			url=url+"?state="+state;
    			url=url+"&county="+county;
    			var target = 'agenda_results';
    			$('loading').show();
    			$('go_back').hide();
    			var myAjax = new Ajax.Updater(target,url, { asynchronous: false, evalScripts: true, method: 'get',
    											onSuccess:
    											function(){
    											document.getElementById('loading').style.display='none';
    											$('go_back').show();
    $('agenda_results').show();											}});
    		
    		}
    		else
    		{
    			alert("Please choose a county and state to update !");
    		}
    	}
    
    	function ShowUploadStatus(state,county)
    	{
    		if (county!="" && state!="")
    		{
    			// here we try to display the status...each city in Real Time !!!
    			var url2="show_status_file.php";
    			url2=url2+"?state="+state;
    			url2=url2+"&county="+county;
    			var target2 = 'show_status';
    			var myAjax2 = new Ajax.PeriodicalUpdater(target2, url2, { method: 'get',
    onSuccess: function(){$('show_status').show(); }, frequency: 2, decay: 1});
    		}
    	}
    and when the page is loaded, I'm using both functions something like this:

    Code:
    onLoad="UpdateAgenda(state,county);ShowUploadStatus(state,county)"
    If someone can give me some idea...pls I've run out of ideas.

  2. #2
    Join Date
    Feb 2003
    Location
    Michigan, USA
    Posts
    5,773
    You'll need to use setInterval() to create an ajax request that repeats itself. It would call some PHP function that checks the session to see which records have been updated. You'd be using asynchronous AJAX in this case.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles