The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

2 Pages V  1 2 >  
Reply to this topicStart new topic
> How do I send a HTTP request from button
goingbush
post Feb 21 2011, 12:03 AM
Post #1





Group: Members
Posts: 9
Joined: 20-February 11
Member No.: 13,932



I'd like to make a webpage interactive and include a button or link in my chicken cam webpage http://chookcam.com so that users can click to activate a chicken feeder in the cameras view.

I have the hardware set up so that if I enter url = server adress/axis-cgi/io/output.cgi?action=1:/1000\ in my browser or via a link a 12volt io relay will turn on for 1000ms then turn off ( / =on, 1000 = time, \ =off )

I will use the relay to control a solenoid to dispense bird seed.

Problem is the hardware server http request opens a new blank page which I am unable to edit , closing the page gets me back to chickencam.com but I simply want users to push a button & the relay activates without any fuss

best i can do so far is http://www.chookcam.com/test.html which opens a popup window that must be closed by the user, rest assured the hardware side is good as I have a buzzer connected & everytime I activate the request the buzzer goes off !!

As you can tell I'm new to this & only know basic html / css have tried searching in vain for a few days to no avail.

cheers ..Don
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Feb 21 2011, 01:44 AM
Post #2


WDG Member
********

Group: Root Admin
Posts: 8,270
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



If I understand you correctly, then you could just delete the onClick attribute.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Barons
post Feb 21 2011, 02:12 AM
Post #3


Member
***

Group: Members
Posts: 70
Joined: 7-November 10
Member No.: 13,091



I really love this idea. I'd like to get some info on your hardware setup if you have a chance. I'd like to get something like that setup for my tarantulas. Prob not the feeding part. They don't eat very often. But the live feed would be cool.

As for your question. I think you need the onClick.

I'm in the process of playing with JavaScript and Ajax. I think Ajax is the stuff that lets you do stuff while staying on the current page.

I'm going to search around abit and see if I can come up with something more detailed. Somthing to the effect of...

function .......code here

$feed = function();
<a href="#" onclick="$function" target="_blank">Feed Em!</a>

This post has been edited by Barons: Feb 21 2011, 02:13 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
goingbush
post Feb 21 2011, 02:27 AM
Post #4





Group: Members
Posts: 9
Joined: 20-February 11
Member No.: 13,932



QUOTE(Darin McGrew @ Feb 21 2011, 01:44 AM) *

If I understand you correctly, then you could just delete the onClick attribute.


Thanks Darin, I tried that but no joy, instead of a popup the whole browser just goes to the http request url and the user has to press the back button.

I uploaded this, it might help explain what I need http://www.chookcam.com/feedtest.html
the problem is in the white css container,
Pressing the link does activate the relay, tho you can't see any result as yet on the webcam

thanks ..Don

This post has been edited by goingbush: Feb 21 2011, 02:30 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
goingbush
post Feb 21 2011, 02:36 AM
Post #5





Group: Members
Posts: 9
Joined: 20-February 11
Member No.: 13,932



QUOTE(Barons @ Feb 21 2011, 02:12 AM) *

I really love this idea. I'd like to get some info on your hardware setup if you have a chance. I'd like to get something like that setup for my tarantulas. Prob not the feeding part. They don't eat very often. But the live feed would be cool.

As for your question. I think you need the onClick.

I'm in the process of playing with JavaScript and Ajax. I think Ajax is the stuff that lets you do stuff while staying on the current page.

I'm going to search around abit and see if I can come up with something more detailed. Somthing to the effect of...

function .......code here

$feed = function();
<a href="#" onclick="$function" target="_blank">Feed Em!</a>


Thanks Barons, there is some info on the hardware setup in the About menu button on the page, another issue with my setup is some visitors complain that the video does not display in IE, not a biggie with me, Thnks for the code tip will have a play with it.
cheers ..Don
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Feb 21 2011, 07:17 AM
Post #6


.
********

Group: WDG Moderators
Posts: 7,858
Joined: 10-August 06
Member No.: 7



QUOTE(goingbush @ Feb 21 2011, 06:03 AM) *

best i can do so far is http://www.chookcam.com/test.html which opens a popup window that must be closed by the user

Seems the javascript should close the popup automatically, but doesn't. Try this:

CODE
<script type="text/javascript">
function popup(mylink, relay)
{
    var popup=window.open(mylink.href, relay, 'width=50px,height=50px,scrollbars=no,left=400,top=300');
    popup.close();
    return false;
}
</script>


Another method might be to put a form (using method POST) on the "output.cgi" page itself, and let the server-side script feed only when the form's submitted but not when the form page is first loaded. But that way you may accidentally feed by reloading the submitted form page.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
goingbush
post Feb 21 2011, 08:21 AM
Post #7





Group: Members
Posts: 9
Joined: 20-February 11
Member No.: 13,932



QUOTE(Christian J @ Feb 21 2011, 07:17 AM) *


Seems the javascript should close the popup automatically, but doesn't. Try this:

CODE
<script type="text/javascript">
function popup(mylink, relay)
{
    var popup=window.open(mylink.href, relay, 'width=50px,height=50px,scrollbars=no,left=400,top=300');
    popup.close();
    return false;
}
</script>




Thanks so much Christian, That almost works, only issue now is it runs a little fast, Have included your code in http://chookcam.com/feedtest2.html for testing, I'll rig a lightbulb in front of the camera tomorrow to demonstrate, Relay triggers about 1 out of 3 clicks, a subsequent click works, is there a way to slow down the popup closing, say about 1 second would be just perfect , perhaps issue is due to latency? either way its great.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Feb 21 2011, 02:08 PM
Post #8


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 17,941
Joined: 9-August 06
Member No.: 6



Actually, clicking that link crashes my browser (K-Meleon, a gecko browser).

Regarding your previous try, with the popup, since you open the window with JavaScript you could let JavaScript close it after an adequate number of seconds. Would that work? If you make the window small it wouldn't be disturbing.

Were are you? I'm guessing Australia. When will the chickens wake up? I want to see them. Boy, will those chooks get fat when you get this working! biggrin.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Feb 21 2011, 02:13 PM
Post #9


.
********

Group: WDG Moderators
Posts: 7,858
Joined: 10-August 06
Member No.: 7



At least in theory it shouldn't matter how fast the popup closes once the HTTP request has been made, but if the browser somehow messes up with the HTTP request anyway you might instead try closing the popup once it has loaded from a script in the actual popup page. Alas I can't remember the details on how to do this without a closing confirmation window.

Perhaps it's easier to use an iframe instead of a popup? Then you don't need to close anything.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Feb 21 2011, 03:06 PM
Post #10


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 17,941
Joined: 9-August 06
Member No.: 6



Yeah, an invisible iframe should work.

I didn't follow what you said about a script in the popup page. Isn't that on another server? And I think goingbush said it can't be edited.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Feb 21 2011, 03:07 PM
Post #11


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 17,941
Joined: 9-August 06
Member No.: 6



They are awake now! This is fun! biggrin.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Feb 21 2011, 04:18 PM
Post #12


.
********

Group: WDG Moderators
Posts: 7,858
Joined: 10-August 06
Member No.: 7



QUOTE(pandy @ Feb 21 2011, 09:06 PM) *

I didn't follow what you said about a script in the popup page. Isn't that on another server?

In that case I guess it will not work.

To the OP: are any visitors from the web allowed to feed the chickens? I'm sure you're aware that this might lead to excessive feeding...
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
goingbush
post Feb 21 2011, 05:27 PM
Post #13





Group: Members
Posts: 9
Joined: 20-February 11
Member No.: 13,932



QUOTE(pandy @ Feb 21 2011, 02:08 PM) *

Actually, clicking that link crashes my browser (K-Meleon, a gecko browser).

Regarding your previous try, with the popup, since you open the window with JavaScript you could let JavaScript close it after an adequate number of seconds. Would that work? If you make the window small it wouldn't be disturbing.

Were are you? I'm guessing Australia. When will the chickens wake up? I want to see them. Boy, will those chooks get fat when you get this working! biggrin.gif


Hey Pandy, when you said your browser crashed I downloaded Camino, a Gecko browser for OSX, It works Ok & whats more the timing issue is gone, The popup works perfect, I tried a few other browsers, Safari crashes on my Intel macbook but is fine on my older PPC Mac, and The timing issue is on Google Chrome, It works flawless in Firefox, Camino and SeaMonkey

yes, Im in Australia, Ill set the Feeder so it only dispenses a small amount of seed & will only fire once every 10 mins, Its mainly to get the chooks in front of the camera for the viewer rather than to actualy feed them because they already have a pellet hopper
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Feb 21 2011, 06:41 PM
Post #14


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 17,941
Joined: 9-August 06
Member No.: 6



The time of day in the hen house and your use of the word chook made me think so. wink.gif

FF doesn't crash for me, only K-Mel, but K-Mel is behind in gecko versions and I don't even have the latest. What make browsers crash though? Have you figured that out?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
goingbush
post Feb 21 2011, 07:54 PM
Post #15





Group: Members
Posts: 9
Joined: 20-February 11
Member No.: 13,932



QUOTE(pandy @ Feb 21 2011, 03:06 PM) *

Yeah, an invisible iframe should work.



Duh!

So Ive spent days trying to get this to work, I even thought iframe but got sidetracked ,

I frame works perfect , thanks Christian and Pandy. I'll just tidy up the css positioning and make a button for the link & jobs done , Even the button dissapears after the user feeds the chooks and it does not crash anything .

test page at http://chookcam.com/feedtest3.html

Will have to spend some time in the shed now making the feeder , might take a few days, once I'm done I'll crank it up on the index page , cheers & thanks heaps !!

This post has been edited by goingbush: Feb 21 2011, 07:55 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Feb 21 2011, 08:51 PM
Post #16


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 17,941
Joined: 9-August 06
Member No.: 6



Hey, K-Mel actually crashes when I click any link on that page, except the one in that's now in the iframe.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Feb 22 2011, 09:22 AM
Post #17


.
********

Group: WDG Moderators
Posts: 7,858
Joined: 10-August 06
Member No.: 7



Windows Vista often shows a crash message for Chrome (I use the Iron version) and Safari when I leave the page, yet Chrome is still there (while Safari goes down for real). This happens both when closing window and following links.

Also the web cam images don't load properly in Opera.

(This based on http://chookcam.com/feedtest3.html )
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Feb 22 2011, 12:42 PM
Post #18


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 17,941
Joined: 9-August 06
Member No.: 6



K-Mel just disappears and it there is a delay before it happens. Just goes poof, no lookup or anything. I didn't understand it had crashed at first and thought I had minimized it by accident.

Tell us when you find out what causes the crashes.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Feb 22 2011, 12:52 PM
Post #19


WDG Member
********

Group: Root Admin
Posts: 8,270
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



The difference between Chrome and Safari when they crash is that Chrome keeps each window or tab in a separate process, so when a process crashes, it takes out only that window or tab. Safari runs everything as a single process, so crashes take out everything.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
goingbush
post Feb 22 2011, 03:57 PM
Post #20





Group: Members
Posts: 9
Joined: 20-February 11
Member No.: 13,932



QUOTE(Christian J @ Feb 22 2011, 09:22 AM) *

Windows Vista often shows a crash message for Chrome (I use the Iron version) and Safari when I leave the page, yet Chrome is still there (while Safari goes down for real). This happens both when closing window and following links.

Also the web cam images don't load properly in Opera.

(This based on http://chookcam.com/feedtest3.html )


I blew the I/O output relay on the video server so changed out to an earlier model that uses activeX instead of J video, can you try this link instead http://chookcam.com/IE.html it should render the video properley.

meanwhile I'll replace the relay in the original server and re install.

Also will download Opera & try to find K-Mel for osx to install & if I find what causes the crashing I'll let y'all know.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

2 Pages V  1 2 >
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 22nd July 2018 - 03:37 PM