Priyanka Gupta
Priyanka Gupta

Reputation: 53

Not able to get data that is in Bengali language from server using jQuery AJAX

I am not able to get data that is in Bengali language from server using ajax. The data from server is getting replaced by something I don't know. But if I normally set the data means not using ajax, data is getting displayed properly. My code is:

<meta content="html/text" charset="UTF-8"> in .jsp file

$.ajax({
   url: "",
   data: "a=a",
   contentType: "charset=utf-8",
   method: "get",
   success:function(){
   },
   failure:function(){
   }
});

I have taken reference from UTF8 encoding not working when using ajax, but even this did not work.

Upvotes: 3

Views: 309

Answers (1)

Tushar
Tushar

Reputation: 87213

The error is in the ajax statement config.

contentType="charset=utf-8",

Here, you should use : instead of =.

See the error highlighted in the code below.

$.ajax({
    url: "YOUR URL HERE?myparam1=value1&param2=value2",
    data: "a=a",
    contentType: "charset=utf-8",
    //         ^
    method: "GET",
    success: function(resp) {},
    failure: function(err) {}
});

Upvotes: 2

Related Questions