The examples in this article describe the Ajax Cross-domain (same base domain name) Form submission method. Share to everyone for your reference. Specifically as follows:
1. Add the following JS statement to the page that makes the AJAX submission:
<script type= "Text/javascript" >
document.domain= "basic domain name";
</script>
2.ajax form when submitting a form, you can use a single form plug-in for jquery Jquery.form.js
Use syntax as follows:
Frompost is the ID $ ("#formPost") for form forms for which you want to collect data
. Ajaxsubmit ({
URL: "Business processing addresses across domains",
cache:false,
dataType: "HTML",
iframe:true,
success:function (data) {
//returns if JSON can do this, the XML format needs to do other processing
eval ("Data=" +data);
if (Data.flag = = ' OK ') {
}
});
3. The return value of a cross-domain business process must contain the following statement
<script type= "Text/javascript" >
document.domain= "basic domain name";
</script>
4. The remaining return value can be json,xml format or other custom format, as long as the client can parse out the desired result
5. So in the AJAX submission of the page can be taken to form a cross-domain submission after the return value, take the return value can be followed by other processing
Description
1. Basic domain name: Two and more than two domain name public part, the public part must contain at least two level domain name or two level domain name above part
2.document.domain= "Basic domain Name"; This sentence is to make the domain name the same, to remove the restrictions on Cross-domain, see: "JS set Document.domain to achieve cross-domain attention point analysis"
3. There are many other solutions to cross domain submissions, such as: "JS homology strategy"
I hope this article will help you with your JavaScript programming.