Ajax processing 301 302

Source: Internet
Author: User

Some Ajax frameworks encapsulate the processing of 301,302 and other return codes, such

 
Function updatepage () {If (request. readystate = 4) {If (request. status = 200) {var response = request. responsetext. split ("|"); document. getelementbyid ("order "). value = response [0]; document. getelementbyid ("Address "). innerhtml = response [1]. replace (/\ n/g, "<br/>");} else alert ("status is" + request. status );}}

If the server returns 301, or the 302 front-end AjaxProgramWhat will be done?

    • 301: Permanent movement
    • 302: Found (the request is redirected to another URL/uri)
    • 305: Use proxy (the request must use a proxy to access the requested resource)

Ajax programmers may not be too concerned about redirection issues due to two reasons:

    • First, Ajax applications are usually written for a specific server-side script, Servlet, or application. For those components that you can't see and disappear, the Ajax programmer is not very clear. So sometimes you know that the resource has been moved (because you have moved it, or you have moved it by some means). Next, you need to modify the URL in the request without encountering such a result.
    • More importantly, Ajax applications and requests are encapsulated in the sandbox. This means that the domain of the web page that provides Ajax requests must be the domain that responds to these requests. Therefore, the web pages provided by ebay.com cannot generate an Ajax-style request for a script running on Amazon.com; ajax applications on ibm.com cannot send requests to Servlets running on netbeans.org.

My question is, why do we need to use 301 and 302 response on our own server?

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.