The strange expression of Ajax in Firefox

Source: Internet
Author: User
1 < Form name = " Registf " Method = " Post " Action = " # " >
2 < P > Registration Name: < Input type = " Text " Name = " User "   / > <Span id = "check"> < / Span > < / P>
3 < P > Registration password: < Input type = " Password " Name = " PWD "   / > < / P >
4 < P > < Input type = " Submit " Name = " SBM " Value = " Register " ID = " SBM "   / > < / P >
5 < / Form>
6 < Button ID = " Test " > Ajax Testing < / Button>

 

The above is a very common form

We need to use ajax to check whether the name has been registered.

So:

1 VaR Xhr = {
2 Cxhr: New XMLHttpRequest () |   New Activexobject ( ' Msxml2.xmlhttp ' ) |   New Activexobject ( ' Microsoft. XMLHTTP ' ),
3 Request: Function (Method, URL, callback, postvars ){
4 Xhr. cxhr. onreadystatechange =   Function (){
5 If (Xhr. cxhr. readystate ! =   4 ) Return ;
6 (Xhr. cxhr. Status =   200 ) ?  
7 Callback. Success (xhr. cxhr. responsetext, xhr. cxhr. responsexml ):
8 Callback. Failure (xhr. cxhr. status );
9 }
10 Xhr. cxhr. Open (method, URL, True );
11 If (Method ! =   ' Post '   | Method ! =   ' Post ' ){
12 Postvars =   Null ;
13 }
14 Xhr. cxhr. Send (postvars );
15 }
16 }
17
18 Window. onload =   Function (){
19 VaR Callback = {
20 Success: Function (Responsetext, responsexml) {document. getelementbyid ( ' Check ' ). Innerhtml = Responsetext; alert (responsetext );},
21 Failure: Function (Statuscode) {alert ( " Failure "   + Statuscode );}
22 };
23 Document. getelementbyid ( 'Sbm ' ). Onclick =   Function (){
24 Xhr. Request ( ' Get ' , " Test. php " , Callback );
25 }
26 }

Behavior in FF:

Modify:

1 Window. onload =   Function (){
2 VaR Callback = {
3 Success: Function (Responsetext, responsexml) {document. getelementbyid ( ' Check ' ). Innerhtml = Responsetext; alert (responsetext );},
4 Failure: Function (Statuscode) {alert ( " Failure "   + Statuscode );}
5 };
6 Document. getelementbyid ( ' Test ' ). Onclick =   Function (){
7 Xhr. Request ( ' Get ' , " Test. php " , Callback );
8 }
9 }

 

Run the following command:

That is to say, FF cannot make Ajax requests when submitting forms. I am studying the problems found today, but I do not know why. If there is any issue, I would like to advise.

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.