Reply
Getting stale data via ajax
Old 07-22-2008, 11:24 PM Getting stale data via ajax
Sleeping Troll's Avatar
Ultra Talker

Posts: 266
Name: Butch Begy
Trades: 0
I call this code from a page via ajax and it does not pick up newly added records just the same old records over and over!

This is my server side script:

Code:
<!-- #include file = "DSN.asp" -->
<%
Set rs=Server.CreateObject("ADODB.RecordSet")
rs.ActiveConnection = conn
rs.open ("SELECT top 1 time FROM calls INNER JOIN cliente INNER JOIN p1 ON cliente.id_cli = p1.clie INNER JOIN p2 ON p1.id_p1 = p2.p1 INNER JOIN p3 ON p2.id_p2 = p3.p2 INNER JOIN p4 ON p3.id_p3 = p4.p3 ON calls.number = p4.c2 WHERE(cliente.id_cli = 30) order by time desc")
Resp = rs.fields("time")
rs.close
Set rs = nothing
conn.close 
Response.Write(Resp)
%>
When I go to this script via url the data is fresh and it poicks up any changes, however when I call it from the client it returns old data, it does not pick up new records, what is going on?

P.S. MSSQL Database.
Sleeping Troll is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 07-23-2008, 02:16 AM Re: Getting stale data via ajax
Super Talker

Posts: 102
Location: http://www.isquaretechnologies.com
Trades: 0
I don't think it will give you different output while calling from client side. I think you are not clearing prev data.. Can I see the client side code ?
__________________
saurabhj is offline
Reply With Quote
View Public Profile Visit saurabhj's homepage!
 
Old 07-23-2008, 05:56 AM Re: Getting stale data via ajax
chrishirst's Avatar
Super Moderator

Posts: 22,281
Location: Blackpool. UK
Trades: 0
Try:

setting the cursorlocation to be clientside (default is serverside)
rs.cursorlocation = adUseClient
http://www.devguru.com/technologies/ado/8650.asp

and a dynamic CursorType
rs.cursortype = adOpenKeyset
http://www.devguru.com/technologies/ado/8651.asp

set these before opening the recordset.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Growing old is mandatory - Growing up is optional
Code Samples | People Counting System | Bits & Bobs
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-23-2008, 07:59 AM Re: Getting stale data via ajax
Sleeping Troll's Avatar
Ultra Talker

Posts: 266
Name: Butch Begy
Trades: 0
I have tried every cursor under the sun and same result, script is queying data not client. but here is clientside script.


Code:
 
function Refresh()
{
var xmlHttp;
try
{ // Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{ // Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
var t=setTimeout("Refresh()",10000);
var Rsp=xmlHttp.responseText;
alert(Tst)
alert(Rsp)
if(Tst != Rsp)
{
Tst = Rsp;
window.location.href="b_monito.asp?"+Rsp;
}
}
}
xmlHttp.open("Get","update.asp",true);
xmlHttp.send(null);
}
Sleeping Troll is offline
Reply With Quote
View Public Profile
 
Old 07-28-2008, 09:31 PM Re: Getting stale data via ajax
Sleeping Troll's Avatar
Ultra Talker

Posts: 266
Name: Butch Begy
Trades: 0
FYI, Response.Expires = -1000
Sleeping Troll is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Getting stale data via ajax
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.11844 seconds with 13 queries