Request :D

C++, C#, Java, PHP, ect...
Post Reply
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Request :D

Post 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
New Site Coming Soon! Stay tuned :D
Falken
Posts: 438
Joined: Fri May 08, 2009 8:03 pm

Re: Request :D

Post 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
--- Game Database ---
For all your game information needs!
Visit us at: http://www.gamedatabase.eu today!
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: Request :D

Post 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
New Site Coming Soon! Stay tuned :D
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: Request :D

Post 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
New Site Coming Soon! Stay tuned :D
User avatar
Lord Strife
Posts: 104
Joined: Wed Oct 28, 2009 3:10 pm

Re: Request :D

Post 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)
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: Request :D

Post by Torniquet »

thanks dude... but tht shit has just confused me 100x more lol :(
New Site Coming Soon! Stay tuned :D
User avatar
Lord Strife
Posts: 104
Joined: Wed Oct 28, 2009 3:10 pm

Re: Request :D

Post 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
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: Request :D

Post 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
New Site Coming Soon! Stay tuned :D
ZeroComp
Posts: 648
Joined: Thu Oct 29, 2009 8:48 pm

Re: Request :D

Post by ZeroComp »

yay torn :D
Coding-PHP, Javascript, C++, HTML, mySQL
Modeling/Art-Blender, GIMP
Games-Unity, Game Maker 8
Post Reply

Return to “Coding”