| 
		
			
			
				
			
			
				 
			
			
				
			
		 | 
		
			
			
				 
			
				
			
		 | 
	||||
| 
				Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.  You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us.  | 
		
		 
		![]()  | 
	
		
			
  | 	
	
	
		
		|||||||
| Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. | 
| 
		 | 
	Thread Tools | 
| 
			
			 | 
		#1 | 
| 
			
			
			
			 Confirmed User 
			
		
			
			
			Join Date: Apr 2004 
				Location: Montreal 
				
				
					Posts: 799
				 
				
				
				
				 | 
	
	
	
	
		
			
			 
				
				How do you call a PHP script from Javascript ?
			 
			I need to call a PHP Script from a Javascript segment of code. I also need the Javascript to stop it's execution while the PHP script does it job. Once the PHP script is done the Javascript must continue where it was. 
		
	
		
		
		
		
			Is such a thing possible. If it's ... how. (I know it's possible with sockets, but seems too much trouble that way...) Thanks 
				__________________ 
		
		
		
		
	
	I have nothing to advertise ... yet.  | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#2 | 
| 
			
			
			
			 No commissions, no fees. 
			
		
			
			
			Industry Role:  
				Join Date: Apr 2003 
				Location: USA 
				
				
					Posts: 17,706
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 PHP is server-side and Javascript is client-side, which means the two will not be able to function together. 
		
	
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#3 | |
| 
			
			
			
			 Sofa King Band 
			
		
			
				
			
			
			Join Date: Jul 2002 
				Location: Outside the box 
				
				
					Posts: 29,903
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 Quote: 
	
  | 
|
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#4 | 
| 
			
			
			
			 Confirmed User 
			
		
			
			
			Join Date: Apr 2004 
				Location: Montreal 
				
				
					Posts: 799
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 No it's possible ... in fact it's even easy to do it ... 
		
	
		
		
		
		
			in Javascript : window.navigate("http://yourPHPScript.php"); and that will do ... but in my case I'm doing it in the onBeforeUnload event. Since I call a other page while the browser is closing the PHP script never receive the info and create an empty record in my DB. So i would need something that loops so the onbeforeUnload don't finish until the php script is done. Basically I need a fucntion that block Javascript execution until the new page isn't completly loaded 
				__________________ 
		
		
		
		
	
	I have nothing to advertise ... yet.  | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#5 | 
| 
			
			
			
			 Sofa King Band 
			
		
			
				
			
			
			Join Date: Jul 2002 
				Location: Outside the box 
				
				
					Posts: 29,903
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 Well, if you're going to a separate page entirely... what you could do is split your function into two new functions, so the first half gets done... then it calls the php script, and then the php script runs a "onLoad" so that it refers back to the original document and the second half of your javascript. 
		
	
		
		
		
		
			
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#6 | 
| 
			
			
			
			 Confirmed User 
			
		
			
			
			Join Date: Dec 2004 
				Location: Belgium 
				
				
					Posts: 248
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 try using an iframe 
		
	
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#7 | 
| 
			
			
			
			 Confirmed User 
			
		
			
			
			Join Date: May 2004 
				Location: ... 
				
				
					Posts: 761
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 lots of ways you can get shit like that to work... usually better to stuff in php first then pass to javascript works fine for me all the time... what exactly are you trying to do? 
		
	
		
		
		
		
			
				__________________ 
		
		
		
		
	
	Programmer ICQ 44035273 | AIM spritwork | Email spritian at spritian dot com  | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#8 | 
| 
			
			
			
			 Too lazy to set a custom title 
			
		
			
				
			
			
			Join Date: Jan 2002 
				Location: Holland 
				
				
					Posts: 9,870
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 you can call an update script from a page in java anytime you want with a little trick 
		
	
		
		
		
		
			put an image on a page like this < img src=whatever height=1 width =1 name="trick" > in a java script you can do the following trick.src = whatever.php hope this helps. 
				__________________ 
		
		
		
		
	
	Don't let greediness blur your vision | You gotta let some shit slide icq - 441-456-888  | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#9 | |
| 
			
			
			
			 Confirmed User 
			
		
			
			
			Join Date: Apr 2004 
				Location: Montreal 
				
				
					Posts: 799
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 Quote: 
	
 
				__________________ 
		
		
		
		
	
	I have nothing to advertise ... yet.  | 
|
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#10 | |
| 
			
			
			
			 Sofa King Band 
			
		
			
				
			
			
			Join Date: Jul 2002 
				Location: Outside the box 
				
				
					Posts: 29,903
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 Quote: 
	
 I dunno... just seems like having javascript do stuff when they close their browser will result in a LOT of lost data and won't save much if anything on serve load.  | 
|
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#11 | 
| 
			
			
			
			 Confirmed User 
			
		
			
			
			Join Date: May 2004 
				Location: ... 
				
				
					Posts: 761
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 easy way to do it is at the top of every script include a small php inc file that just monitors the ref, dt, ip etc inserting to your db... you can also append what they clicked on in the uri so you can track it that way as well... no need for javascript. 
		
	
		
		
		
		
			obviously if there is no more activity, they've closed the browser, because up until that point you've monitored where they are going in the site 
				__________________ 
		
		
		
		
	
	Programmer ICQ 44035273 | AIM spritwork | Email spritian at spritian dot com  | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#12 | |
| 
			
			
			
			 Confirmed User 
			
		
			
			
			Join Date: Apr 2004 
				Location: Montreal 
				
				
					Posts: 799
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 Quote: 
	
 Might represent a good saving (Processing power) if my site gets lot of traffic. 
				__________________ 
		
		
		
		
	
	I have nothing to advertise ... yet.  | 
|
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#13 | 
| 
			
			
			
			 Confirmed User 
			
		
			
			
			Join Date: Apr 2004 
				Location: Montreal 
				
				
					Posts: 799
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 [QUOTE=naitirps]easy way to do it is at the top of every script include a small php inc file that just monitors the ref, dt, ip etc inserting to your db... you can also append what they clicked on in the uri so you can track it that way as well... no need for javascript. 
		
	
		
		
		
		
			QUOTE] I know I could do this like you wrote, but it will result in way to much connection to my database... 
				__________________ 
		
		
		
		
	
	I have nothing to advertise ... yet.  | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#14 | 
| 
			
			
			
			 Confirmed User 
			
		
			
			
			Join Date: May 2004 
				Location: ... 
				
				
					Posts: 761
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 so dump to flatfile, and update hourly to your db then 
		
	
		
		
		
		
			or do it solely in xml... 
				__________________ 
		
		
		
		
	
	Programmer ICQ 44035273 | AIM spritwork | Email spritian at spritian dot com  | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#15 | |
| 
			
			
			
			 No commissions, no fees. 
			
		
			
			
			Industry Role:  
				Join Date: Apr 2003 
				Location: USA 
				
				
					Posts: 17,706
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 Quote: 
	
 Good luck with that -lol.  | 
|
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#16 | 
| 
			
			
			
			 Too lazy to set a custom title 
			
		
			
				
			
			
			Join Date: Jan 2002 
				Location: Holland 
				
				
					Posts: 9,870
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 cookies is he answer 
		
	
		
		
		
		
			
				__________________ 
		
		
		
		
	
	Don't let greediness blur your vision | You gotta let some shit slide icq - 441-456-888  | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 |