jquery .load and .ajax return different values, why?

1

Hello,

My problem is that using .load or .ajax on the same address, I get different data values. Here's an example:

 <span id="charset"></span><br/>
 <span id="d_nome"  title=".load"></span>
 <span id="d_nome2" title=".ajax"></span>

with the following script:

$.ajaxSetup({

 beforeSend: function(dd,obj){
                 obj.dataType= "text";
                 obj.dataTypes=["text"];
                 return obj;
                },
  success: function(data){
                 console.log(".statusCode: "+data); 
                }
});

$(document).ready( function () {

$("#charset").html(document.charset);
$("#d_nome").load("/getDescricao?id=2");


$.ajax({
      url: "/getDescricao?id=2",
      success: function(data){
        $("#d_nome2").html(data);  
      }
    });
});

I get this result:

UTF-8
Farm�cias
Farmácias

I use the formatting in ajaxSetup to ensure that the orders made are exactly the same. I also tested it without ajaxSetup. The result should be the same since the request and answer are the same but somehow JQuery changes the formatting of the word 'Pharmacy' when doing .load but when done by .ajax the word comes correct.

Thanks for the help.

    
asked by anonymous 06.03.2016 / 17:16

0 answers