my current 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.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); } }
returns the error
line 39 in the line[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]I know the original websocket works,Code:try{ socket.send(msg); log('Sent: '+msg); } catch(ex){ log(ex);
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.
Might be an issue with the quotes? I know javascript is funky about that. or maybe i'm missing something bigger? thanksCode: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); } }


Reply With Quote
Bookmarks