Ajax basics-Chapter 3)

Source: Internet
Author: User

Head request:

HEAD requests are very simple; you can use "head" (instead of "get" or "Post") as the first parameter to callopen()Method.

When you generate a head request like this, the server does not return a real response like a get or POST request. On the contrary, the server only returnsHeader)This includes the last modification time of the content in the response, whether the requested resource exists, and many other useful information.

Output the content of the Response Header obtained from the head request:

Function updatepage (){
If (request. readystate = 4 ){
Alert (request. getAllResponseHeaders ());
}
}
Therefore, to obtain the response length, you only need to callrequest.getResponseHeader("Content-Length");

Example: iframe.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

      <title>Example of remote scripting in an IFRAME</title>
    <script type="text/javascript">
    function handleResponse() {
      alert('this function is called from server.html');
    }
  </script> 
  <body>
    
   <Iframe id="beforexhr"
  name="beforexhra" src="netease_jimmy_missyou1024.jpg"
  style="border:10px solid blue" align=center 
  width="500" height="500" marginHeight=20 marginWidth=20 scrolling="yes"
  frameborder="0"></iframe>

 <a href="server.html" target="beforexhra">call the server</a>
 
  </body>

Server.xml

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

      <title>the server</title>
    <script type="text/javascript">
    window.parent.handleResponse();
  </script> 
  <body>
  </body>

Note:

window.parent:

Obtains the parent window or parent frame of a framework. The parent of the top-level window references itself.

Target attribute:

1. _ blank
<A href = "document.html" target = "_ blank"> my document </a>
The browser opens a new window to display the document.html document.
2. _ parent
<A href = "document.html" target = "_ parent"> my document </a>
Pointing to parent frameset document
3. _ Self
<A href = "document.html" target = "_ Self"> my document </a>
Transfer the document to the current page
4. _ top
<A href = "document.html" target = "_ top"> my document </a>
Drop all webpages and replace the frameset document with document.html

Tip 1: Make others' page boxes unable to reference Your webpage
Add <base target = "_ top"> to the file header.

Tip 2: open a connection on the current page or refresh it and submit it to the current page.
Add <base target = "_ Self"> to the file header.

 

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.