Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 0.70 KB  |  hits: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Uncaught SyntaxError: Unexpected token ILLEGAL when returning a £ symbol using JSON
  2. var currency = "";
  3. var price = "";
  4.  
  5.  
  6. $.ajax({
  7.   type: 'GET',
  8.   url: '../JSONDeliveryPrice/',
  9.   dataType: 'json',
  10.   success: function (data) {
  11.     price = eval(data.price);
  12.     currency = eval(data.currency);
  13.   },
  14.   async: false
  15. });
  16. console.log(price);
  17. console.log(currency);
  18.        
  19. public virtual ActionResult JSONDeliveryPrice()
  20.         {
  21.             string currency = "£";
  22.             decimal price = 123;            
  23.             return Json(new { price = price, currency = currency }, JsonRequestBehavior.AllowGet);
  24.         }
  25.        
  26. ...
  27. success: function (data) {
  28.     price = data.price;
  29.     currency = data.currency;
  30. },
  31. ...