Submission canceled because the form is not connected solution after AJAX post jump page form

Source: Internet
Author: User


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;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.