Jquery .html and acentuation


Jquery .html and acentuation

首先,我为我的英语感到抱歉。

好吧,我是jquery的新手。我正在做一个启用/禁用按钮,使用$.post();

:

$.post(goURL, {data: foo}).done(function(data){
     $('.error').html(data.type, data.message);
});

在我的php脚本中,我有:

<?php
     function enableThis()
     {
          $act = updateDatabase();
          if($act)
          {
               $data['type'] = 'success';
               $data['message'] = 'á é í ó ú';
          }else
          {
               $data['type'] = 'error';
               $data['message'] = 'á é í ó ú';
          }
          json_encode($data);
          exit;
     }

就是这样,类型总是正确的,但是消息返回undefined。我放了这个之后:

<?php header('Content-Type: text/html; charset=utf-8');

消息返回带有下划线的字符(不是这个,只是示例)/156a8。但是不要在。errordiv中填充消息

我做错了什么?

jQuery html()只接受一个参数,使用逗号发送两个参数

$('.error').html(data.type + ', ' + data.message);

当您添加第二个参数时,它不会输出-> FIDDLE