1. Create a.html
Copy codeThe Code is as follows:
<! Doctype html>
<Html>
<Head>
<Meta charset = 'utf-8'>
<Title> iframe ajax call </title>
</Head>
<Body>
<Form action = 'B. php' method = 'post' name = ''id ='' target = 'formtarget'>
<Input type = 'text' name = 'username' id = ''placeholder = ''value = ''/>
<Input type = 'submit 'name = ''value = 'Submit'/>
<Span id = 'msg '> </span>
</Form>
<Iframe src = ''name = 'formtarget' id = 'formtarget' style = 'display: none'> </iframe>
</Body>
</Html>
2. Create B. php
Copy codeThe Code is as follows:
<? Php
Echo"
<Script>
Parent.doc ument. getElementById ('msg '). innerHTML = 'iframe-type ajax call successful! ';
Alert ('You entered: {$ _ POST ['username']} ');
Window. setTimeout (function (){
Parent. window. location. reload ();
},3000 );
</Script>
";
3. Access: http: // localhost/a.html
Effect