I’ve written a PHP-script that parses a list from remote website and output the result as JSON form my iPhone app which is built on Titanium Mobile.
This is my header: header('content-type:application/json;charset=utf-8');
Also tried with ISO-8859-1 but problem persists.
I print the textResponse in the titanium console and see that the &-characters are represented as &. Same result when I make the same request in my web browser.
I try to replace & with & using replace(‘&‘, ‘&’) but it has no effect, & is still &.
var events = JSON.parse(this.responseText);
Titanium.API.info(events);
for (var i = 0; i < events.length; i++) {
var id = events[i].id;
var title = events[i].title;
var amp = title.search('&');
if (amp != -1) {
title.replace('&', '&');
Titanium.API.info(amp);
Titanium.API.info(title);
}
var row = Titanium.UI.createTableViewRow({title: title, id: id, hasChild: true});
rowData[i] = row;
}
1 Answer