By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,347 Members | 1,355 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,347 IT Pros & Developers. It's quick & easy.

Connecting source code to ajax and commands elsewhere after so much time

P: 13
Hello, I could use some advice on the best way to connect to some php in my source code using ajax. So that the php will re-execute after so much time with a script elsewhere on the server. Please let me know, thanks. Tami
Dec 3 '06 #1
Share this Question
Share on Google+
4 Replies

Expert 2.5K+
P: 4,258
Have a look at some of the demos in the Ajax scripts .
There are some scripts in there (esp. RSS type) that use JS timers to refresh the content after every x seconds. You'll probably find something useful there.

Ronald :cool:
Dec 3 '06 #2

P: 13
Hello, can ajax connect to the server for a server side script function only and NOT a page?

For instance lets say I want part of the main page to have a refresh without a full refresh every so often. There is a function on the server that executes another after so much time. Can the ajax connect to it? Thank you very much.
Dec 4 '06 #3

Expert 100+
P: 1,208
Yes this can be done.
Dec 4 '06 #4

P: 13
Hello, the following is a simple http request that just shows the source code in an alert when you put test.php in the browser, just to show the http request is working. How can I make the exact same http request re-execute after so much time? I tried putting a javascript setTimeout on it but seem to be doing it wrong. How would a setTimeout be attached to this to make the request call again? Or is there a better way than a setTimeout? I really need to get this working. Hope someone can help. Thank you very much.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="">

<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
<style type="text/css">
<script type="text/javascript" src=""></script>
<script type="text/javascript">
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
if (!xmlhttp && window.createRequest) {
try {
xmlhttp = window.createRequest();
} catch (e) {
}"GET", "test.php",true);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
Dec 10 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.