AJAX question..

F

Frances

am just starting out with AJAX, got example from here,
http://www.w3schools.com/ajax/ajax_example.asp working fine

but I have a question (actually I have many questions, but will start
with this one for now..)

in this line of code

var url="gethint.asp?sid="+Math.random()+"&q="+str

what is purpose of 'sid' param in query string, this is not used at all
in code, I even changed this line to..

var url="gethint.asp?q=" + str

and it worked just as well.. thank you...
 
M

Martin Honnen

Frances wrote:

in this line of code

var url="gethint.asp?sid="+Math.random()+"&q="+str

what is purpose of 'sid' param in query string, this is not used at all
in code,

It might be an attempt to prevent the browser from returning a cached
resource.
 
T

the DtTvB

Andy said:
sid usually means 'session identification' i.e. it's the server's way of
remembering that you are the same user across a series of otherwise
unrelated page requests. Http is a stateless protocol which doesn't
remember who you are between one request and the next, so people have to
invent tricks like this to get round that.

Yes, it is, but not in this one..
That number is "not" session id, but it's a random number just to
prevent cache.
Like if I do the first request on 7:50:21 and I do the same URL request
again on 7:50:30, the browser may get the cached (saved) or outdated
data on 7:50:21. I have to put some random number on my URL request.
Sometimes I even used Math.random() + '' + new Date().getTime()

My question is why did they used the word 'sid' while it's not sid?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top