Quantcast
Channel: Willem Allan » PHP
Viewing all articles
Browse latest Browse all 11

Problemas com acentuação jQuery-Ajax-PHP

$
0
0

Para arrumar os acentos quando utilizado o ajax do jquery, basta adicionar o código a seguir nas páginas que retornam os dados.

1
2
3
<?php
header("Content-Type: text/html; charset=ISO-8859-1",true);
?>

Veja o exemplo abaixo:

Página retorno.php

1
2
3
4
<?php
header("Content-Type: text/html; charset=ISO-8859-1",true);
echo "olá";
?>

Página envia.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
      <script>
       $(document).ready(function(){
 
 
        $("#submit").click(function(){
 
 
          $.post("retorno.php",
          {
            usuario: $("#usuario").val(),
            senha: $("#senha").val()
 
          }, function(data){
            $("#msg").html(data);
 
          });
 
        });
 
      });     
      </script>

Viewing all articles
Browse latest Browse all 11

Latest Images

Trending Articles





Latest Images