Page 1 of 1

Request :D

Posted: Fri Dec 25, 2009 11:05 pm
by Torniquet
i need a ajax script that runs like every 10 minutes that executes a php script.

i have tried farting about with an altered code i use for other things... but it dont seem to want to work :( lol

so if anyone could do me the honours. it would be much appreciated

Re: Request :D

Posted: Fri Dec 25, 2009 11:36 pm
by Falken
Torniquet wrote:i need a ajax script that runs like every 10 minutes that executes a php script.

i have tried farting about with an altered code i use for other things... but it dont seem to want to work :( lol

so if anyone could do me the honours. it would be much appreciated
As I don't believe in copy-pasting when learning I wont make the script for you, but show you how and where you can learn to make on ;)

Start by learning timers in javascript:
http://www.w3schools.com/js/js_timing.asp

then learn XMLHttpRequests in javascript
http://www.w3schools.com/Ajax/ajax_xmlhttprequest.asp

and finally combine what you learned from both! :)

Quite good learning experience to read both and then make a working script of both yourself! Both the great satisfaction when you finally got it working and you learn a lot more when you have to think alittle and not copy paste a tutorial. :)

Good Luck! If you got any general javascript question while doing it feel free to ask, or read the basics here: http://www.w3schools.com/js/default.asp

Re: Request :D

Posted: Sat Dec 26, 2009 12:13 am
by Torniquet
thanks falk ^^

i dont like copy n pasting either. but i have had no luck in learning ajax / JS what so ever.

wish me luck :D

Re: Request :D

Posted: Sat Dec 26, 2009 2:11 am
by Torniquet
ok im getting a head ache with this xhlhttp request bit :(

i dont quite understand it...

do i need to fart about with the whole onreadystate stuff if i am only running a script and not changing something on the page??

i have tried with and without it.. but its still not running the script. what am i doing wrong :( lol

js file

Code: Select all

function run_timer(){
	
	var url="../_scripts/test.php"
	xmlhttp.open("GET",url,true)
	xmlhttp.send(null)
	alert('5 seconds!')
	var t=setTimeout("session_update()",60000)
	
}
then in my php script..

Code: Select all

<head>
<script src="../_javascript/testtimer.js" type="text/javascript"></script>
</head>

<body onload="run_timer()">
</body>
i am only trying to run a bleedin mysql insert lol

Re: Request :D

Posted: Sat Dec 26, 2009 3:52 am
by Lord Strife
http://www.reynoldsftw.com/2009/02/usin ... witter-api change the getsearch.php page and change the time (remember 1000 = 1 sec in javascript)

Re: Request :D

Posted: Sat Dec 26, 2009 4:00 am
by Torniquet
thanks dude... but tht shit has just confused me 100x more lol :(

Re: Request :D

Posted: Sat Dec 26, 2009 4:25 am
by Lord Strife
download the zip file (read toward the bottom after the example code he gives) inside the zip is a working example that you can see in action which explains things ALOT , basicallyt ita a ajax/js timer that runs a php script (getsearch.php in the zip) the example uses the twitter API as a example but you can change getsearch.php tp whatever you want , then it give a html page (html code) with it in use

Re: Request :D

Posted: Sat Dec 26, 2009 4:19 pm
by Torniquet
lol I HAVE DONE IT!!!!!

WOOOOOOOOO and on my own (well using the supplied sites by falk :p)

i was just in the middle of writing saying its the xmlhttp request tht wasnt working when it dawned on me that i might need to create the objxmlhttp thingy.

which that site failed to mention -.- lol

anyways i got it working now. lets hope it does what i want it to XD

much love x

Re: Request :D

Posted: Sat Dec 26, 2009 4:39 pm
by ZeroComp
yay torn :D