页面编码为utf-8
js:
- var encode = encodeURI("楼");
- //页面编码为gbk2312要再一次encode=encodeURI(encode);
- var data = 'id=' + $("#UserId").val() + '&roomname=' + $("#RoomNumber").val() +'&floorname=' + $("#FloorSelect").val() + encode;
- $.ajax(
- {url:"../PHP/FloorManage.PHP?method=addroom",type:'get',data:data,async:'false',success:function()
- {
- alert(data);
- }
- }
- );
PHP:
$str=urldecode($_GET['floorname']);
//js页面编码为gbk2312的时候
//$ str =iconv("UTF-8","GB2312",$ str); //编码转换