Broblem with ajax data

Broblem with ajax data

DimaSiKDimaSiK Posts: 6Questions: 0Answers: 0
edited November 2010 in General
I try to load data using ajax. I have next data generated by server side:
{"sEcho": 1, "iTotalRecords": 8, "iTotalDisplayRecords": 8, "aaData": [ ["1", "news", "The mouse doesn\"t work in windowed FAR."],["2", "news", "Does not work with cyrillic file names on Novell."],["3", "news", "This is the bug in the Novell Client on Windows."],["4", "news", "Open the Control Panel and load the Regional and Language Options."],["5", "news", "You need to refresh the plugins\' cache. Just run the supplied."],["6", "news", "Performance Counters are missing."],["7", "news", "But this feature is correctly supported by only."],["8", "promo", "Using Del in this dialog you can unmap"]] }

Problem was in this words: doesn\"t, plugins\' but why? All needed symbols are normally quoted. What is problem? If I remove all quotes in this case all works fine.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    If you run it thought jsonlint.com ( http://jsonlint.com ) you'll see what it's not valid JSON, which is why it's failing.

    Allan
  • DimaSiKDimaSiK Posts: 6Questions: 0Answers: 0
    Hm, but very strange, why this - \' not correct in json. I use addslashes php function for quoting data. Maybe this is not by the standards of json?
  • DimaSiKDimaSiK Posts: 6Questions: 0Answers: 0
    I check JSON standard and yes, this situation - \' not allowed. Tnx.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    It's just not needed - strings in JSON require double quotes, so there is no need to escape single quotes :-). With PHP using json_encode() is safest way of creating a JSON string.

    Allan
This discussion has been closed.