Reference to this article: https://segmentfault.com/q/1010000000473230 Error: getting error "form submission canceled because the" form is not Connected
Then in: http://stackoverflow.com/questions/42053775/ Getting-error-form-submission-canceled-because-the-form-is-not-connected found the answer, adding $ (document.body). Append (Form) , and then solve the problem.
The specific principle is as follows:
Details:according to the HTML standards, if the ' form is ' not ' associated browsing context (document), form submission'll Be aborted.
HTML SPEC. 4.10.21.3.2
This spec is applied in Chrome.
var url = "__root__/index.php/home/apiinfo/register"; RequestData = {' email ': email, ' pwd ':p wd};
$.post (URL, requestdata, function (data) {
if (data!= null) {
alert (data);
}else{
var form = $ ("<form method= ' post ' ></form>");
Form.attr ({"Action": "__root__/index.php/home/apiinfo/sucess"});
$ (document.body). append (form);
Form.submit ();
}
});
/////////////////////////////////////////
Later, with form submission, Ajax validation, in a different way to achieve:
var url = "__root__/index.php/home/apiinfo/isexist";
RequestData = {' email ': email};
var isOk = true;
$.ajax ({
url:url,
type: ' Get ',
Data:requestdata,
async:false,//critical operation, you need to wait until result to perform the following Operation
success: function (data) {
alert (data);
IsOk = false;
}
});
return isOk;