/    Sign up×
Community /Pin to ProfileBookmark

socket.send Troubleshooting Javascript websocket send

my current code

[CODE]function send(){
var txt,msg,address;
txt = $(“msg”);
address = txt.value
msg = ({“op”:”addr_sub”, “addr”:”address”});
if(!msg){ alert(“Message can not be empty”); return; }
txt.value=””;
txt.focus();
try{ socket.send(msg); log(‘Sent: ‘+msg); } catch(ex){ log(ex); }
}[/CODE]

I took a script I found and simply added the var address. I set the address equal to what the msg used to be. The input of the form. I then set the msg to what I want the form to send to the websocket.

returns the error

[QUOTE]

[Exception… “Component returned failure code: 0x80460001 (NS_ERROR_CANNOT_CONVERT_DATA)” nsresult: “0x80460001 (NS_ERROR_CANNOT_CONVERT_DATA)” location: “JS frame :: XXXXXXXXXX.org/POS/POS.php :: send :: line 39” data: no]

[/QUOTE]

line 39 in the line

[CODE]try{ socket.send(msg); log(‘Sent: ‘+msg); } catch(ex){ log(ex);[/CODE]

I know the original websocket works,

I am trying to make it simpler to send a command to a websocket. On the default code you can copy and paste {“op”:”addr_sub”, “addr”:”$bitcoin_address”} replace the address and hit send. Im trying to make so you just need to enter in the address and hit send.

the code originally looked like this.

[CODE]function send(){
var txt,msg;
txt = $(“msg”);
msg = txt.value;
if(!msg){ alert(“Message can not be empty”); return; }
txt.value=””;
txt.focus();
try{ socket.send(msg); log(‘Sent: ‘+msg); } catch(ex){ log(ex); }
}[/CODE]

Might be an issue with the quotes? I know javascript is funky about that. or maybe i’m missing something bigger? thanks

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @XMLnewbi spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...