When I try to return a £ symbol from a JSON call, I get an error in chrome: Uncaught SyntaxError: Unexpected token ILLEGAL
var currency = "";
var price = "";
$ .ajax({
type: 'GET',
url: '../JSONDeliveryPrice/',
dataType: 'json',
success: function (data) {
price = eval(data.price);
currency = eval(data.currency);
},
async: false
});
console.log(price);
console.log(currency);
currency should equal “£” but instead I get that error. Do I have to encode/decode the value somehow? Also, price outputs correctly if I return just the price.
EDIT:
public virtual ActionResult JSONDeliveryPrice()
{
string currency = "£";
decimal price = 123;
return Json(new { price = price, currency = currency }, JsonRequestBehavior.AllowGet);
}