这其实是编码造成的,很简单,只需要在ajax的data参数加个encodeURI()即可。
另外还有类似的escape()和encodeURIComponent(),三者之间的区别详见http://www.17jquery.com/javascript/46071/
一般情况下,ajax提交表单写入到DB的时候,用到的是encodeURI较多,注意大小写。
$.ajax({
url:"../Ajax/Ajax_SaveFixAddress.asp",
type:"POST",
data:encodeURI("a_id="+a_id+"&m_id="+m_id+"&AddrName="+txtAddrName+"&AddrContact="+txtAddrContact+"&AddrContry="+txtAddrContry+"&AddrDetail="+txtAddrDetail+"&AddrZipcode="+txtAddrZipcode+"&AddrTelNum="+txtAddrTelNum+"&AddrCellphone="+txtAddrCellphone),
cache:"false",
success: function(msg){
if(msg==1){
$('#btnSubmit'+n).attr("src","../images/btn_saved.gif");
}else{
alert('Update Address Failed. \nPlease try later.');
}
}
});