I am trying to get Javascript to send a command to the server.
The original script I could just type that in to the form replace the address and hit send.Code:{"op":"addr_sub", "addr":"address"}
Trying to get it so you can just enter the address and hit send.
I modified the function send() by adding a var address. I set that equal to the input from the form; what used to be msg. And set msg to what I want the script to send the server.
Im getting the following error.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); } }
[Exception... "Component returned failure code: 0x80460001 (NS_ERROR_CANNOT_CONVERT_DATA)" nsresult: "0x80460001 (NS_ERROR_CANNOT_CONVERT_DATA)" location: "JS frame :: XXXXX.POS/POS.php :: send :: line 39" data: no]
This is the original script
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); } }
Sorry if this is a repost browser froze submitting.
thinking I'm not using the quotes right? I know JavaScript is weird about quotes. I tried /" but was getting syntax errors.
I can post the whole script if needed.


Reply With Quote
Bookmarks