Function ChkJson (strJson) {// determine whether the Json format is correct
If (strJson = null | strJson = "")
Return true;
Try {
JSON. parse (strJson );
Return true;
}
Catch (ex ){
Return false;
}
}
Function validateXML (strXml, msg ){
Debugger;
Msg = msg + "\ r error message: \ r ";
/// Code for IE
// If (window. ActiveXObject ){
// Var xmlDoc = new ActiveXObject ("Microsoft. XMLDOM ");
// XmlDoc. async = "false ";
// XmlDoc. loadXML (document. all (txt). value );
// If (xmlDoc. parseError. errorCode! = 0 ){
// Txt = "Error Code:" + xmlDoc. parseError. errorCode + "\ n ";
// Txt = txt + "Error Reason:" + xmlDoc. parseError. reason;
// Txt = txt + "Error Line:" + xmlDoc. parseError. line;
// Alert (msg + txt );
// Return false;
//} Else {
//// Alert ("no error found ");
// Return true;
//}
//}
// Code for Mozilla, Firefox, Opera, Chrome, etc.
// Else
If (document. implementation. createDocument ){
Var parser = new DOMParser ();
// Var text = txt;
Var xmlDoc = parser. parseFromString (strXml, "text/xml ");
If (xmlDoc.doc umentElement. nodeName = "parsererror "){
Alert (msg + xmlDoc.doc umentElement. childNodes [0]. nodeValue );
Return false;
} Else {
// Alert ("no error found ");
Return true;
}
}
/// Code for IE
Else if (window. ActiveXObject )){
Alert ('use Chrome browser ');
Return false;
}
Else {
Alert ('your browser cannot process XML verification ');
Return false;
}
}