I am considered about XSS vulnerability!
I have web site, where All data b/w web server and client is transferred via XHR - JSON and browser javascript doing the rest to display the site.
When client submit data, here is my code BEFORE data to be recorded in DB (PHP):
$string = trim($_POST['user_input']);
$string = strip_tags($string);
$string = mysql_real_escape_string($string);
When the server getting data form database PHP code is following:
$string = htmlspecialchars($db_value);
and then
header('Content-Type: application/json; charset=utf-8');
print json_encode($string);
Is this enough to protect me against XSS?