Replace JSON Values

This is my first talk about JSON, and I need help (sorry if I'm wrong).

I have data in a MySql database with strange values (ex. è - à - ù - ò.....), and when I have a response from JSON, my result of the field is null.

Follow the code I'm using! Can someone help me how to replace these letters or solve the problem.

THANKS!

I get my data

{"items":
 {
  "id":"305",
  "title":"Il manipolatore",
  "description":null
 }
 ....
}

This is my code:

var serviceURL = "app/testE/services/";
var employees;

$('#employeeListPage').bind('pageinit', function(event) {
getEmployeeList();
});

function getEmployeeList() {
$.getJSON(serviceURL + 'getemployees.php', function(data) {
$('#employeeList li').remove();
employees = data.items;
$.each(employees, function(index, employee) {
$('#employeeList').append('<li><a href="employeedetails.html?id=' + employee.id + '">' + '<img src="' + employee.img + '" width="80px" height="80px" />' +
'<h4>' + employee.title + '</h4>' +
'<p>' + employee.description + '</p>' +
'</a></li>');
});
$('#employeeList').listview('refresh');
});
}
+4
source share
1 answer

Use $. ajax () , not $ .getJSON (), and then set charset to utf-8.

http://api.jquery.com/jQuery.ajax/

0
source

All Articles