I'm not sure exactly what it is that you seek to do, but it sounds like you want to screen a user input string to prevent them from including any of those special characters. bradgrafelman has a good point in suggesting that you might want to consider a whitelist. A whitelist would be easier if you want to permit only alphanumeric characters and spaces or something. On the other hand, I can't help but wonder if the preg_* functions would work well with all languages. E.g., can you specify a character range in kanji or mandarin like you can specify [A-Z]?
At any rate, if you want to detect the presence of those characters above, I would recommend something like this:
$forbidden_chars = array(
"(",
"-",
"&",
"'",
"\"",
"/",
"\\",
"%",
"*",
"#",
")"
);
// you would need to change appropriately for your AJAX script
$user_input = "nothing to see he're";
foreach($forbidden_chars as $fc) {
if (strpos($user_input, $fc) !== FALSE) {
die($fc . " is forbidden!");
}
}
// if you reach this point in your code, you can be sure that there are no forbidden chars in $user_input