Ajax and Ajax Frameworks

I have been a developer for nearly 20 years and a web developer for about 10 years. Over the years, I have considered creating a blog to share the things I have learned (and am learning) about web design and development, but I never seemed to have the time. When I began learning about web development using Ajax and Ajax Frameworks, I decided to take the time to create this blog.

My intention for this blog is to focus primarily on Ajax Frameworks, but since web development requires knowledge of many technologies, I will occasionally write about things such as CSS, Javascript, PHP, MySQL, Flash, etc.

Lately, I have been using JQuery as my primary Ajax tool. Although I have used other Ajax Frameworks in the past (Dojo Toolkit, Yahoo! User Interface Library, Scriptaculous/Prototype), JQuery has thus far been the easiest to learn. In my first few posts I will discuss some of the JQuery Plugins that I have created. Some of these include: a plugin for Google Maps (jquery.imGoogleMaps), Form validation and submission  (jquery.imValidateForm), Page Populater (jquery.imPagePopulate), and a plugin to create lists (jquery.imList).

While I am still learning about some of the other Ajax Frameworks, I hope that what I have learned will be helpful to others. Just remember, “When you can pull the pebbles from my hand…”

JQuery 1.4, YUI: JSON ParseError – Quotes Required

Thursday, January 14th, 2010

Someone just sent me a message asking me to update my imBannerRotater plugin because they were receiving a parseerrormessage with JQuery 1.4.

I tested the plugin with JQuery 1.4 and I too received the parseerror message. I knew immediately that the problem was with the Json record that was returned via an ajax request. Looking at the json record, I noticed that quotes were placed around the value, but not the name/key, so I added the quotes:

?View Code JAVASCRIPT
// originally
{name: "joneil.jpg", url: "http://www.imdb.com/character/ch0005968/"}
 
// changed to
{"name": "joneil.jpg", "url": "http://www.imdb.com/character/ch0005968/"}

I tested and no longer received the parseerror message.

The reason I knew that the error was due to the json record is because I ran into a similar problem with YUI last week. I received a parse error with a json record because I used single quotes rather than double quotes. I thought it was odd (and I was a bit displeased).

Knowing about the problem with YUI and single quotes, I tested json object above using single quotes:

?View Code JAVASCRIPT
{'name': 'joneil.jpg', 'url': 'http://www.imdb.com/character/ch0005968/'}

I again received the parseerror message. So you must use double quotes. I went back and read the Json specs. It mentioned placing double quotes around the value, but did not mention anything about placing quotes (double or otherwise) around the the name/key. But YUI and JQuery 1.4 both require it so it must be required.

Related posts

3 Responses to “JQuery 1.4, YUI: JSON ParseError – Quotes Required”

  • jQuery 1.4 Released Says:


    [...] JQuery 1.4, YUI: JSON ParseError – Quotes Required … – Someone just sent me a message asking me to update my imBannerRotater plugin because they were receiving a parseerrormessage with JQuery 1.4. I tested the. Ads by Lake Quincy Media Other Related Items: Start, Run & Grow Your BusinessStart, Run & Grow Your Business is a great collection of tools, resources, information, and discounts to help you get your business up and running qui… Read More > Londons Times Funny Food Coffee other Digestibles – Javascript – Coffee Gift Baskets – Coffee Gift BasketJavascript Coffee Gift Basket is measuring 9×9x4. Contains 15oz mug, BONUS free set of 4 coasters, biscotti and 5 blends of gourmet coffee. French V… Read More > Learning Javascript Level 1 Keystone If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!Related PostDo you Need My Help?jQuery Expand/Collapse Using Head TagsHead First Ajax – BookAjax: The Definitive GuideDoes jQuery Make Us Lazy? Bookmark to: Hide Sites Posted in none | Tags: javascript, jQuery, json, release [...]
  • Chris Carr Says:


    Thanks for sharing all the great code on your web site!

    With respect to the double-quote requierment for JSON names: are you looking at http://www.json.org/ for the standard? It’s pretty clear about the quote requirement. It defines an object as a series of name/value pairs separated by commas and surrounded by curly braces. It further states that the name is a string (see the first syntax diagram as well as the side-bar), and it goes on to define strings as “A string is a collection of zero or more Unicode characters, wrapped in double quotes”.

    Far from mentioning that you must place double-quotes around the value, it defines a value as having any of seven possible types, only one of which (string) requires double-quotes.

    What’s not clear to me is whether the json.org home page is considered the authoritative specification. Do you have a better source?

    Feel free to delete this comment unpublished.

  • admin Says:


    Json.org is the best source for json specs (and is the site that I use). But in my post, I mentioned that the specs specify that double quotes are required for the ‘value’, but does mention anything about placing quotes (double or otherwise) around the ‘name/key’ (unless I’m reading the specs incorrectly).

    I noticed that it was required with JQuery 1.4 (not sure when it became required with YUI). Prior to using JQuery 1.4, I rarely ever placed quotes (double or otherwise) around the name/key.

    Thanks.

CommentLuv Enabled