User avatar
davef21370
Posts: 897
Joined: Fri Sep 21, 2012 4:13 pm
Location: Earth But Not Grounded

Sloppy Webcam

Sat May 18, 2013 2:59 pm

I have a simple webcam set up over my home network. It uses a Python script to take an image every few seconds and save it to the relevant folder which all works fine. My problem is with the HTML to update the image....

Code: Select all

<html>
	<head>
		<title>
			Webcam
		</title>
		<meta http-equiv='refresh' content='3'; url='index.html'>
	</head>
	<body>
		<div align='center'>
			<img src="image.jpg">
		</div>
	</body>
</html>
This forces the browser to update the entire page every 3 seconds which is a bit rubbish to say the least.

What would be a more elegant solution? (I'm fine with coding but new to php, java, etc.)

Any help would be great.
Dave.
Apple say... Monkey do !!

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: Sloppy Webcam

Wed May 29, 2013 3:13 pm

Do you know about https://en.wikipedia.org/wiki/Ajax_(programming) AJAX?

Also, jQuery.
http://jquery.com

There are 2 starting points.
Essentially, you need to code it up so jQuery uses ajax to update the image only.
Last edited by SirLagz on Thu May 30, 2013 12:59 am, edited 1 time in total.
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

User avatar
davef21370
Posts: 897
Joined: Fri Sep 21, 2012 4:13 pm
Location: Earth But Not Grounded

Re: Sloppy Webcam

Wed May 29, 2013 5:21 pm

Thanks for the reply, I did a quick search based on AJAX and ended up with a JavaScript example here http://www.tek-tips.com/viewthread.cfm?qid=1546531

Cheers.
Dave.
Apple say... Monkey do !!

Return to “Networking and servers”