Zero G
Zero G

Reputation: 127

XMLHttpRequest - Send a string instead of a number

I'm using this webpage, found here: https://wp.josh.com/2014/05/01/a-platform-for-casual-encounters/

<!DOCTYPE html>
<head>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0'>
<title>Toggle</title>
</head>
<body><center>
<script>
function send(s) {
    r=new XMLHttpRequest();
    r.open('GET','/cgi-bin/control.cgi?COMMAND='+s+'&'+(new Date()).getTime(),false);
    r.send(null);
 }
</script>
<H1>Toggle</H1>
<button onclick='send(1);'>On</button>
<button onclick='send(0);'>Off</button>``
</center></body>

It works perfectly, i can receive the numbers on my terminal. Now i'm trying to send a string instead of "0" or "1". I tried to use <button onclick='send(ON);'>On</button> but i can only receive the first letter. I think the problem is the script, how can i edit it to accept strings? I'm new to HTML, i need some support. Thank you!

Upvotes: 0

Views: 72

Answers (1)

Anoos Sb
Anoos Sb

Reputation: 453

try:

<button onclick="send('ON');">On</button>

Upvotes: 1

Related Questions