Ajax attempt (2)

Source: Internet
Author: User
Tags blank page

After the last Ajax attempt, I want to apply ajax to the password modification interface. First, I want it to jump out of the corresponding name.
However, the problem arises. The last time I used to create an ASP file separately, this time I didn't want too many files and fewer files, which made it easier to see. So I want to query Code Also on the password change page. Here I encountered two problems: how to change to the POST method, because the POST method does not allow me to write so many parameters; how to make aspx only return the specified content, instead of <HTML> First, there is a ready-made code on the network. The original code is as follows:
Function txts61bh_keydown ()
{
VaR xhttp = new activexobject ("Microsoft. XMLHTTP ");
Xhttp. Open ("get", "password. aspx? S61bh = "+ document. All [" txts61bh "]. Value, false );
Xhttp. Send ();
Eval (xhttp. responsetext );
}
Now you only need to change it to the following:
Function txts61bh_keydown ()
{
VaR para = "s61bh =" + document. All ["txts61bh"]. value;
VaR xhttp = new activexobject ("Microsoft. XMLHTTP ");
Xhttp. Open ("Post", "password. aspx", false );
Xhttp. setRequestHeader ("Content-Type", "application/X-WWW-form-urlencoded ")
Xhttp. Send (para );
Eval (xhttp. responsetext );
}
The main difference is to add a variable para and add para in brackets when sending the variable. Now it seems that the POST method also needs to write parameters, without implementing what I previously imagined.
During the test, I found that the POST method can be implemented even if xhttp. setRequestHeader is not written.

The second problem is that the network is rarely mentioned. Most of them refer to "Creating a blank page ......" This method, but you can use response. End. However, I tried it and it didn't work. After a long time, I found that I commented out xhttp. setRequestHeader during my first test. If I wrote this sentence, response. end would be okay. Angry!
Therefore, for aspx to return some content, you can use response. End to return the content "<HTML>

In addition, the method for trying to get is also xhttp. setRequestHeader. Otherwise, "<HTML>

 

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.