Jump to content

[SOLVED] Maintain Scroll Position Following DB Update Using AJAX


dlebowski

Recommended Posts

I have a php site that is using AJAX and I am running into a problem that I don't know how to solve.  I imagine this will be done in the java portion of AJAX, but need assistance to confirm this. 

 

After I update my database using an update query, the results are then populated back using AJAX.  The issue I am running into is that I need the results to come back and the scrollbar to maintain it's position prior to the update query being executed.  The list of items that are returned is very large and it is a hassle to have to scroll back down to find the next item to update in the list.  Any assistance on this would be great.  Thanks!

 

Ryan

Below is the code I am currently using.  Any help would be appreciated.  Thanks!

 

var xmlHttp

function updatelotslive(str, str2, str3, str4, str5, str6, str7, str8, str9, str10)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
} 
var url="update.php"
url=url+"?ud_LotID="+str
url=url+"&ud_LotNumber="+str2
url=url+"&ud_LotTitle="+str3
url=url+"&ud_SellingPrice="+str4
url=url+"&ud_LotPaymentExempt="+str5
url=url+"&ud_Buyer="+str6
url=url+"&ud_OnlineOnsite="+str7
url=url+"&ud_AbsenteeBid="+str8
url=url+"&ud_SellerNumber="+str9
url=url+"&ud_LotAuctionDate="+str10
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange = function(){
	if(xmlHttp.readyState < 4){
		document.getElementById('txtHint').innerHTML = '<h2>Loading...</h2>';
	}
	if(xmlHttp.readyState == 4){
		document.getElementById('txtHint').innerHTML = xmlHttp.responseText;
	}
}
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function deletelotslive(str)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
} 
var url="deletelotslive.php"
url=url+"?ud_LotID="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange = function(){
	if(xmlHttp.readyState < 4){
		document.getElementById('txtHint').innerHTML = '<h2>Loading...</h2>';
	}
	if(xmlHttp.readyState == 4){
		document.getElementById('txtHint').innerHTML = xmlHttp.responseText;
	}
}
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
//Internet Explorer
try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
}
return xmlHttp;
}

 

  • 7 months later...

hi~  there.

 

I am having exactly same problem.

 

follow is the situation..

datas are updated by ajax call and server return result  saying work is done.

the result is received by javascript (ajax callback..) and next, without user intervention javascript call another ajax process to retrieve updated data and show it on browser.

 

but the middle of process..    page scrolle to top causing mising previous point.

 

if this is solved.  could you tell me how you solve this?

 

thnak you in advance.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.