解决方案 »

  1. 页面统一编码设置为utf-8 或者gb2312。如果不行则进行编码解码
      

  2. <!DOCTYPE html>
    <html>
    <head lang="en">
        <meta charset="UTF-8">
        <link href="./css/styles.css" rel="stylesheet" type="text/css"/>
        <script src="./js/jquery-1.7.2.js" type="text/javascript"></script>
        <script src="./js/LWJs.js" type="text/javascript"></script>
         
                 <script  type="text/javascript">
                     window.onload = function () {
                         var url = location.search;
                         var Request = new Object();
                         if (url.indexOf("?") != -1) {
                             var str = url.substr(1);//去掉?号
                             strs = str.split("&");
                             for (var i = 0; i < strs.length; i++) {
                                 Request[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
                             }
                         }
                         var guestinfo = Request["guest"];
                         var contype = Request["contype"];
                         var tableid = Request["tableno"];//桌号name
                         var table_id = Request["table_id"];//桌号id
                         var waiter = Request["waiter"];
                         var guestqty = Request["personnum"];//人数
                         var busiman = Request["busiman"]
                         var regional_id = Request["regional_id"];//区域id
                         document.getElementById('guestinfo').value = guestinfo;
                         document.getElementById('contypeinfo').value = contype;                     var waiterid = Request["waiterid"];
                         var busimanid = Request["busimanid"];
                         document.getElementById('waiterid').value = waiterid;
                         document.getElementById('busimanid').value = busimanid;                     document.getElementById('table_id').value = table_id;   //桌号id
                         document.getElementById('regional_id').value = regional_id;   //桌号id                     if (guestqty == "") { guestqty = "" + 1; }                      $('#tableid').val(tableid); //桌号name
                         $('#waiter').val(waiter); //服务员
                         $('#guestqty').val(guestqty);
                         $('#busiman').val(busiman);                      $('#p_tableid').val(table_id); //桌号name
                         $('#p_waiter').val(waiterid);
                         $('#p_guestqty').val(guestqty);
                         $('#p_busiman').val(busimanid);
                         $('#mmenu').html(""); 
              
                         //获取菜品导航
                         $.ajax({
                             type: "post",
                             url: "../Account/DishesFile.ashx?sing=dishestype",
                             dataType: 'text',
                             success: function (data) {
                                 var dataObj = eval("(" + data + ")");
                                 var id = '2E0B5A3D-56F0-4E25-8341-E6077ECC774A';
                                 var menudiv = document.getElementById('mmenu');
                                 for (var i = 0; i < dataObj.length; i++) {
                                     var parid = dataObj[i].ParentId;
                                     if (parid === id) {
                                        // alert('父节点');
                                         var maindiv = document.createElement('div');
                                         maindiv.id = "main_" + dataObj[i].Id;
                                         maindiv.className = 'main_menu';
                                         maindiv.setAttribute('onClick', "getsubmenu($(this).find('img')[0].id)");
                                         var mainlabel = document.createElement('label');
                                         mainlabel.innerHTML = dataObj[i].Name;
                                         var mainimg = document.createElement('img');
                                         mainimg.id = dataObj[i].Id;
                                         mainimg.setAttribute('src', './images/sub_menu.png');
    //                                     mainimg.setAttribute('onClick', 'getsubmenu(this.id)');
                                         maindiv.appendChild(mainlabel);
                                         maindiv.appendChild(mainimg);
                                         menudiv.appendChild(maindiv);
                                         var subdiv = document.createElement('div');
                                         subdiv.id = dataObj[i].Id + '_box';
                                         subdiv.className = 'menu_box';
                                         subdiv.style.display = 'none';
                                         menudiv.appendChild(subdiv);
                                        // alert('父节点创建成功');
                                     }
                                 }
                                 for (var i = 0; i < dataObj.length; i++) {
                                     var parid = dataObj[i].ParentId;
                                     if (parid != id) {
                                         //alert('子节点'); 
                                         var subdiv = document.createElement('div');
                                         subdiv.className = 'sub_menu'; 
                                         subdiv.setAttribute('onClick', 'GerDishesType(this.id)');
                                         subdiv.id = dataObj[i].Id;
                                         var pardiv = document.getElementById(dataObj[i].ParentId + "_box");
                                         pardiv.appendChild(subdiv);
                                         var sublabel = document.createElement('label');
                                         sublabel.id = dataObj[i].Id;
                                         sublabel.innerHTML = dataObj[i].Name;
                                         subdiv.appendChild(sublabel);
                                         var sublabel1 = document.createElement('label');
                                         sublabel1.className = 'menulist';
                                         sublabel1.innerHTML = ' >>&nbsp;&nbsp;';
                                         subdiv.appendChild(sublabel1);
                                         //                    alert('子节点创建成功');
                                     }
                                 }
                               
                             }
                         });
                       
      

  3. 二楼说的有道理   , 一般乱码都是编码格式不统一造成的   
    页面统一编码设置为utf-8 或者gb2312。
      

  4. 看下这个http://www.jb51.net/article/24097.htm
      

  5. 我觉得应该是文件格式不统一,不是简单的设置编码格式就行的,编码格式使用UTF-8,文件格式可以用记事本打开后另存为,文件名下面有格式选择,尽量用UTF-8统一保存,例如:如果html页面文件是UTF-8,而脚本文件是ANSI格式,就容易出现此类问题
      

类似问题 »