javascript - Sinch IM: Page reloads after message is sent -
i have simple form contains 2 inputs, asking recepient(s) , message content.
upon submission of the form, message sent appropriate recepient(s). first time form submitted, goes well. second time form submitted, page reloads , message not sent.
document.getelementbyid("imform__sendmessage").addeventlistener("click", function (event) { event.preventdefault(); var message = messageclient.newmessage(document.getelementbyid("imform__recepientfield").value.trim(), document.getelementbyid("imform__messagefield").value.trim()) messageclient.send(message).fail(function (error) { console.log(error); }); return false; });
the above is "relevant" code, can find full js file here , can find html file here.
where errors may ask. on first sending, no errors flagged. on second sending, page refreshes catch error (if there one)
i have looked @ im sample quite lot of times. , there no distinct differences in between our codes except fact that, in sample, use jquery...which not.
Comments
Post a Comment