dongmei5168 2015-09-25 10:12
浏览 78
已采纳

通过jquery ajax方法提取的值中的字体字符问题

I am using jquery ajax to display some values inside the label when some value is selected from select box. but the value that i want to display in label is some different font and I think that is why the value is displayed with some question mark characters with black quad box as background [#nb-am-h��#w] . How to avoid this:

//Javascript code
<script type="text/javascript">
    $("document").ready(function(){
        var id=$(this).val();
        //alert(id);

        $.ajax({
            type: "POST",
            url: "ajax.php",
            data: {id:id},
            cache: false,
            success: function(html){
                //alert(html);
                $("#malid").show();
                /*$('#malid').css("font-family", "malfont");*/
                $("#malid").html(html);
            } 
        });
    );

HTML code

<div>
  <label>Book</label>
  <select id="bookname">
  <?php 
      for($i=0;$i<$count;$i++)
      {
      ?>
           <option  value="<?php echo $bookid[$i];?>"><?php echo    $book_name[$i];?> </option>
      <?php
      } 
  ?>
  </select>
  <label id="malid" style="display:none;font-family: 'malfont';"></label>
 </div>

//Php code inside ajax.php
if(isset($_POST['id']))
{
    $id=$_POST['id'];

    $book_results = $mysqli->query("SELECT book FROM booktable where book_id='$id'");
    $row = $book_results->fetch_assoc();
    $book = $row['book'];
    echo $book;  
} 
  • 写回答

2条回答 默认 最新

  • dousao6313 2015-09-26 11:01
    关注

    I got a solution for my issue. I just included the below line in my Ajax page and it is working fine now.

    header('Content-Type: text/html; charset=ISO-8859-15');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line