Ajax---"Pseudo" Ajax

Source: Internet
Author: User

views.py

def ajax1 (Request):

ret={' status ': ' True ', ' message ': ' Successful '}

Return HttpResponse (Json.dumps (ret))


<iframe id= "I1" name= "Ifra" ></iframe>
<form id= "I2" method= "Get" action= "ajax1.html" target= "Ifra"# (onload= "Loadifram (this);") >
#target等于ifram的name, to bind the From to Ifram, if the onload event is bound on the label, the parameter this is required, and the function is defined above, otherwise the binding cannot be found
<input type= "text" value= "1111111111" >
#以下两种提交方法效果相同
#<input type= "Submit" value= "Submission" >
<a onclick= "AjaxSubmit5 ()" > Submit </a>
</form>
<script src= "/static/js/jquery-3.3.1.js" ></script>
<script>
function Loadifram () {#起到回调函数的作用
#两种方法找到ifram接收的内容, the following onload binding method, this is the Ifram tag
# Console.log (This.contentWindow.document.body.innerHTML);
# Console.log ($ (' #i1 '). Contents (). Find (' body '). html ());
var content=this.contentwindow.document.body.innerhtml
var res=json.parse (content)
if (res.status) {
Alert (res.message)
}
}
function AjaxSubmit5 () {
document.getElementById (' I1 '). Onload=loadifram;#提交时为ifram绑定onload事件
document.getElementById (' I2 '). Submit ();

}

Ajax---"Pseudo" Ajax

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.