gpt4 book ai didi

javascript - onsubmit javascript 和表单

转载 作者:行者123 更新时间:2023-12-02 17:31:05 27 4
gpt4 key购买 nike

onsubmit不起作用的问题当我点击提交时,它会继续执行操作而不是提交

<form action="http://www.client.ad-saver.com/Registration/SimpleRegister?      email=yusuyaauu@gmail.com" onsubmit="return myFuncmyFunc();"  method="POST">
<input class="email" type='text' name='email' placeholder='E-mail' value=""/>
<input class="submit" id="sub" type="submit" value='Регистрация' name='reg'/>
</form>

这是我的js:

function myFuncmyFunc () {
var crossdomainrequest = {
callbackCounter: 0,
fetch: function (url, callback) {
var fn = 'JSONPCallback';
window[fn] = this.evalJSONP(callback);
url = url.replace('=JSONPCallback', '=' + fn);
var scriptTag = document.createElement('SCRIPT');
scriptTag.src = url;
document.getElementsByTagName('HEAD')[0].appendChild(scriptTag);
},
evalJSONP: function (callback) {
return function (data) {
var validJSON = false;
if (typeof data == "string") {
try {
validJSON = JSON.parse(data);
} catch (e) {
}
} else {
validJSON = JSON.parse(JSON.stringify(data));
}
if (validJSON) {
callback(validJSON);
} else {
throw ("JSONP call returned invalid or empty JSON");
}
}
}
}

crossdomainrequest.fetch("http://www.client.ad-saver.com/Registration/EmailValidation?email=wdlebedcom", function (data) {
alert(data.message);
});
}

我需要收到警报,然后在提交后获取操作和操作位置

最佳答案

myFuncmyFunc() 应返回 false 以防止将表单提交到服务器

关于javascript - onsubmit javascript 和表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23057264/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com