可以用uriencode或escape对字符串编码,如果有英文引号则用反斜杠转义。
用特殊字符的实体编码代替字符,如用<代表<,>代表>, "e;代表双引号, &代表&等。
js中的特殊字符,加上转义符\ 。
例如:
var txt="We are the so-called "Vikings" from the north." document.write(txt) 【错误】
var txt="We are the so-called \"Vikings\" from the north." document.write(txt) 【正确】
对特殊字符编码
这跟ajax有什么联系?