Page reloading when hitting enter on a form

时间:2018-05-06 17:06:09

标签: javascript

Yes this question has been asked for, no the answers don't seem to be working for me.

Simply put, here's the code:

with gzip.open('music_train.tar.gz', 'rb') as f:
    for files in f : 
        mono, fs = librosa.load(files, sr = 44100)

using TypeError: lstat() argument 1 must be encoded string without null bytes, not str doesn't have any effect, where as using <form id="frm1" onsubmit="preventDefault();"> Message: <input type="text" name="message"><br> <input type="button" onclick="sendMessage()"> </form> <script> function sendMessage() { var message = document.getElementById("frm1").message.value; socket.emit('browsermsg', {data: message}) } $("frm1").submit(function (e) { e.preventDefault(); sendMessage(); alert("call some function here"); }); </script> prevents the from from being submitted at all when enter is pressed.

I want the form to submit when enter is pressed, but then to also not reload the page. I'm failing to see where in code the page feels the need to reload when the enter key is pressed at all, I'm assuming it's something built into JS?

1 个答案:

答案 0 :(得分:4)

class Students: def __getitem__(self, key): return getattr(self, key) ... # as before print(getattr(s, 'Jake'), s['Jake']) should be 12 12

As you are selecting from by Id, this is how you use the selector with id $("frm1").submit(function (e) {