最近很长一段时间都在想办法处理Ajax跨域的问题,远程的数据取到了,可就是老是解析不了,一解析就报unterminated string literal
//resultString = resultString.replace("\n\r", "<br> ");//这句会报错,去掉
resultString = resultString.replace("\r\n", "<br> ");//这才是正确的!
resultString= resultString.replace("\t", " ");
resultString =resultString.replace(" ", " ");
//resultString=resultString.replace("\"", "\\"+"\"");//如果原文含有双引号,这一句最关键!!!!!!
再补充一些:
resultString =resultString.replace("<", "<");
resultString =resultString.replace(">", ">");
resultString =resultString.replace("&", "&");
resultString=resultString.replace("\n\n","");
resultString = resultString.replace("\"","\\\\\"");
resultString = resultString.replace("\n", "");