Ajax compatibility related issues in Firefox browser, the program runs normally in IE

Source: Internet
Author: User
Tags urlencode
Ajax compatibility problem in Firefox browser, the program runs normally in IE
var Xmlhttp=false;
function Createxmlhttp () {
try{
Xmlhttp=new XMLHttpRequest ();
}catch (Trymicrosoft) {
try{
Xmlhttp=new ActiveXObject ("msxml2.xmlhttp");
}catch (Othermicrosoft) {
try{
Xmlhttp=new ActiveXObject ("Microsoft.XMLHTTP");
}catch (failed) {
Xmlhttp=false;
}
}
}
if (!xmlhttp) {
Alert ("Cannot create XMLHttpRequest Object! ");
}
}
function Ajaxcheck () {
var num=document.myform.uname.value;//getting the form's data
var url= "check.php?n=" +num;
Createxmlhttp ();
Xmlhttp.open ("GET", url,true);//The true representation here is an asynchronous request
Xmlhttp.onreadystatechange=updatepage;
Xmlhttp.send (NULL);
}

function Updatepage () {
if (xmlhttp.readystate==4) {
var Response=xmlhttp.responsetext;
if (response== "OK") {
Document.myform.nameerr.value= "√";
return true;
}else if (response== "no") {
document.myform.nameerr.value= "x user name is occupied";
return false;
}else{
Document.myform.nameerr.value= "Server is having problems";
return false;
}
}
}




Code as above, I am using AJAX to detect the existence of the user name, in Firefox, if the name of the English mother, can be normal, if the Chinese name will not be judged, how the matter ah????

------Solution--------------------
Should be in the Ajaxcheck send the request when the error, may be the problem caused by Chinese,
You can be in the check.php page echo user name, see if it is garbled, if it is garbled, use UrlEncode to deal with
------Solution--------------------
var url= "check.php?n=" +num;
Url=encodeuri (URL);
------Solution--------------------
In the check.php page echo user name, see if it is garbled, if it is garbled, use UrlEncode to deal with
------Solution--------------------
Explore
Reference: What is database encoding? What is the registration page script encoding? Are the two consistent? , inconsistent words have to use the Iconv () function to convert the data character encoding
My database, database, table, fields are used gb2312, in check.php also added mysql_query ("set character set gb2312");
  • 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.