Code for filtering strings returned by Ajax

Source: Internet
Author: User

The JS Code is as follows.
After Ajax is called. A strange problem. The returned resultString value is "OK" but is not equal to the string "OK.
What parameters are added to the results returned by Ajax calling out. println?
The comments cannot be filtered out.
Which of the following experts has encountered similar problems.
How to solve the problem.
Let's talk about it. Out. println (); what is returned.
Js Code
Copy codeThe Code is as follows:
// Download locally
Function FTPTest (ip, port, username, password, filedir ){
Alert ("test ");
CreateXMLHttpRequest ();
Var url = "DataExportAjaxServlet. doajax? OsFlg = ftptest & ip = "+ ip +" & port = "+ port;
XmlHttp. open ("GET", url, true );
XmlHttp. onreadystatechange = goCallback;
XmlHttp. send (null );
}

Js Code
Copy codeThe Code is as follows:
// Callback function
Function goCallback (){
If (xmlHttp. readyState = 4 ){
If (xmlHttp. status = 200 ){
// Obtain the execution result
Var resultString = xmlHttp. responseText;
Alert (resultString );
// Var newstrb = resultString. replace ("\ r", "123 ");
// Comment out this sentence first
// Alert ("newstrb-" + newstrb + "-");
If ("OK" = newstrb ){
Alert ("successful ");
Document. getElementsByName ("buttonSave") [0]. disabled = "";
} Else {
Alert ("<bean: message key =" ftptest.info. fail "/> ");
Document. getElementById ("errorMessage"). innerHTML = 'test failed ';
Document. getElementsByName ("buttonSave") [0]. disabled = "true ";
}
}
}
}

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.