DUMB question ? Server trip without a page refresh or reload possible ?

M

Mel

i would like to have a link, such that when the user clicks on it, a script
is fired to go to server and check for page updates, if any, it should
request a reload, else stay silend (terminate)

is such thing possible ?

thanks
 
M

Martin Honnen

Mel said:
i would like to have a link, such that when the user clicks on it, a script
is fired to go to server and check for page updates, if any, it should
request a reload, else stay silend (terminate)

is such thing possible ?

<form action="">
then make the page an ASP or PHP (or whatever you use on the server) and
let it return the HTTP status code 204 if there is no new data,
otherwise send the new data.
 
M

Mel

how can i return "HTTP status code 204" from my cgi script ?

any example is appreciated
 
M

Martin Honnen

Mel said:
how can i return "HTTP status code 204" from my cgi script ?

How about looking in the documentation of your favourite CGI
language/package on how to set HTTP response codes?
As you are asking in a JavaScript group I will show you an ASP solution
with JavaScript, if that doesn't help you then use an appropriate group
for your server side language, after checking its documentation and FAQ
list.

<%@ Language="JavaScript" %>
<%
function checkForUpdates () {
// simply returning a number here
return Math.floor(Math.random() * 10) + 1;
}
var update = checkForUpdates();
if (update < 5 && Request.ServerVariables('REQUEST_METHOD') == 'POST') {
Response.Status = '204 No Content';
Response.End();
}
%>
<html lang="en">
<head>
<title>form updated occasionally</title>
</head>
<body>
<form action="" method="POST">
<div>
<label>
user value:
<input type="text" name="uservalue">
</label>
<input type="submit" value="check for updates">
</div>
<div>
<span>
updated value:
<%= update %>
</span>
</div>
</form>
</body>
</html>
 

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,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top