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条)

报告相同问题?

悬赏问题

  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能