Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Client Script to trigger Postback 1

Status
Not open for further replies.

jfrost10

Programmer
Jun 3, 2001
2,004
CA
Hey guys,

Lookin' for a little help here: I'm using asp.net (yes yes, there is an ASP.NET forum, but so far there's only about 4 or 5 of us posting there, and someone here might have the answer), and writing a chat application for work. I need my page to post back to the server ever 10 seconds to refresh the messages on the screen.

Problem: the popular "meta tag http-equiv='refresh'" doesn't actually postback (in .NET anyways), so thats out of the picture. Is there any other way to force a postback without having the client interact with the page?

Thanks guys,

Jack
 
This should work nicely:

<script language=javascript>
function postBack(){
var i;
for (i=0;i<=10;i++)
setTimeout('submitIt(i);',i*1000);
}
function submitIt(theSeconds){
if (theSeconds==10)
document.formName.submit();
}
</script>

replacing formName with the name of your recursive form, sending all the variables along with it.

:)
paul
penny.gif
penny.gif
 
Hey Paul, thanks for the post. I'm having some probs though getting the script to run.

It doesn't error out on my page (no little triangle with the ! on it), but it doesn't postback. I added the formname like you instructed and placed the script inside my header (been a while since I've used javascript, is that where it goes?). Any thoughts? It could be a .NET thing, but I doubt it...I'm probably just missing something.

Any thoughts?

Thanks,
Jack
 
need to call the function onLoad

<body onLoad=&quot;postBack();&quot;>

Sorry for the omission.

:)
paul
penny.gif
penny.gif
 
You the man! Works like a charm

thanks buddy
:)

Jack
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top