Well, safe or not, when you are using jQuery, you're better to use the $.getJSON() method, not $.ajax():
$.getJSON(url, function(data){
alert(data.exampleType);
});
eval()
is usually considered safe for JSON parsing when you are only communicating with your own server and especially when you use a good JSON library on server side that guarantees that generated JSON will not contain anything nasty.
Even Douglas Crockford, the author of JSON, said that you shouldn't use eval()
anywhere in your code, except for parsing JSON. See the corresponding section in his book JavaScript: The Good Parts
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…