[jQuery] Re: G is undefined
Ok, figured out that data.items is undefined. Not sure why because here's the json my url returns: [{ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpgquot; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http:// www.xxx.com/image/4852.jpgquot; alt=quot;quot;gt;}] On Jun 29, 10:33 am, expresso dschin...@gmail.com wrote: I get the following error: G is undefined init()()jquery-12.min.js (line 12) (?)()()Carousel.aspx (line 30) I()jquery-12.min.js (line 19) F()()jquery-12.min.js (line 19) [Break on this error] (function(){var l=this,g,y=l.jQuery,p=l.each (function(){o.dequeue(this,E)})}}); in jquery-1.3.2.min.js when I call this method of mine: $.getJSON(http://localhost:59396/xxx/xxxHandler.ashx? action=xxxjson, function(Data) { $.each(Data.items, function(i, item) { alert('got here'); carousel.add(i, mycarousel_decodeEntities(item.ImageTag)); if (i == 3) return false; }); }); I know I can get inside function(Data){ and that the error starts at $.each I believe
[jQuery] Re: G is undefined
Ok, figured out that data.items is undefined. Not sure why because here's the json my url returns: [{ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpgquot; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http:// www.xxx.com/image/4852.jpgquot; alt=quot;quot;gt;}] On Jun 29, 10:33 am, expresso dschin...@gmail.com wrote: I get the following error: G is undefined init()()jquery-12.min.js (line 12) (?)()()Carousel.aspx (line 30) I()jquery-12.min.js (line 19) F()()jquery-12.min.js (line 19) [Break on this error] (function(){var l=this,g,y=l.jQuery,p=l.each (function(){o.dequeue(this,E)})}}); in jquery-1.3.2.min.js when I call this method of mine: $.getJSON(http://localhost:59396/xxx/xxxHandler.ashx? action=xxxjson, function(Data) { $.each(Data.items, function(i, item) { alert('got here'); carousel.add(i, mycarousel_decodeEntities(item.ImageTag)); if (i == 3) return false; }); }); I know I can get inside function(Data){ and that the error starts at $.each I believe
[jQuery] Re: G is undefined
Ok, figured out that data.items is undefined. Not sure why because here's the json my url returns: [{ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpgquot; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http:// www.xxx.com/image/4852.jpgquot; alt=quot;quot;gt;}] On Jun 29, 10:33 am, expresso dschin...@gmail.com wrote: I get the following error: G is undefined init()()jquery-12.min.js (line 12) (?)()()Carousel.aspx (line 30) I()jquery-12.min.js (line 19) F()()jquery-12.min.js (line 19) [Break on this error] (function(){var l=this,g,y=l.jQuery,p=l.each (function(){o.dequeue(this,E)})}}); in jquery-1.3.2.min.js when I call this method of mine: $.getJSON(http://localhost:59396/xxx/xxxHandler.ashx? action=xxxjson, function(Data) { $.each(Data.items, function(i, item) { alert('got here'); carousel.add(i, mycarousel_decodeEntities(item.ImageTag)); if (i == 3) return false; }); }); I know I can get inside function(Data){ and that the error starts at $.each I believe
[jQuery] Re: G is undefined
So is this valid JSON that jQuery can parse? or do I need an initial level such as Images: [{Images : [{ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpg; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http:// www.xxx.com/image/4852.jpg alt=quot;quot;gt;} ]] On Jun 29, 10:37 am, expresso dschin...@gmail.com wrote: Ok, figured out that data.items is undefined. Not sure why because here's the json my url returns: [{ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpg; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http://www.xxx.com/image/4852.jpgalt=quot;quot;gt;}] On Jun 29, 10:33 am, expresso dschin...@gmail.com wrote: I get the following error: G is undefined init()()jquery-12.min.js (line 12) (?)()()Carousel.aspx (line 30) I()jquery-12.min.js (line 19) F()()jquery-12.min.js (line 19) [Break on this error] (function(){var l=this,g,y=l.jQuery,p=l.each (function(){o.dequeue(this,E)})}}); in jquery-1.3.2.min.js when I call this method of mine: $.getJSON(http://localhost:59396/xxx/xxxHandler.ashx? action=xxxjson, function(Data) { $.each(Data.items, function(i, item) { alert('got here'); carousel.add(i, mycarousel_decodeEntities(item.ImageTag)); if (i == 3) return false; }); }); I know I can get inside function(Data){ and that the error starts at $.each I believe
[jQuery] Re: G is undefined
So is this valid JSON that jQuery can parse? or do I need an initial level such as Images: [{Images : [{ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpg; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http:// www.xxx.com/image/4852.jpg alt=quot;quot;gt;} ]] On Jun 29, 10:37 am, expresso dschin...@gmail.com wrote: Ok, figured out that data.items is undefined. Not sure why because here's the json my url returns: [{ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpg; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http://www.xxx.com/image/4852.jpgalt=quot;quot;gt;}] On Jun 29, 10:33 am, expresso dschin...@gmail.com wrote: I get the following error: G is undefined init()()jquery-12.min.js (line 12) (?)()()Carousel.aspx (line 30) I()jquery-12.min.js (line 19) F()()jquery-12.min.js (line 19) [Break on this error] (function(){var l=this,g,y=l.jQuery,p=l.each (function(){o.dequeue(this,E)})}}); in jquery-1.3.2.min.js when I call this method of mine: $.getJSON(http://localhost:59396/xxx/xxxHandler.ashx? action=xxxjson, function(Data) { $.each(Data.items, function(i, item) { alert('got here'); carousel.add(i, mycarousel_decodeEntities(item.ImageTag)); if (i == 3) return false; }); }); I know I can get inside function(Data){ and that the error starts at $.each I believe
[jQuery] Re: G is undefined
So is this valid JSON that jQuery can parse? or do I need an initial level such as Images: [{Images : [{ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpg; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http:// www.xxx.com/image/4852.jpg alt=quot;quot;gt;} ]] On Jun 29, 10:37 am, expresso dschin...@gmail.com wrote: Ok, figured out that data.items is undefined. Not sure why because here's the json my url returns: [{ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpg; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http://www.xxx.com/image/4852.jpgalt=quot;quot;gt;}] On Jun 29, 10:33 am, expresso dschin...@gmail.com wrote: I get the following error: G is undefined init()()jquery-12.min.js (line 12) (?)()()Carousel.aspx (line 30) I()jquery-12.min.js (line 19) F()()jquery-12.min.js (line 19) [Break on this error] (function(){var l=this,g,y=l.jQuery,p=l.each (function(){o.dequeue(this,E)})}}); in jquery-1.3.2.min.js when I call this method of mine: $.getJSON(http://localhost:59396/xxx/xxxHandler.ashx? action=xxxjson, function(Data) { $.each(Data.items, function(i, item) { alert('got here'); carousel.add(i, mycarousel_decodeEntities(item.ImageTag)); if (i == 3) return false; }); }); I know I can get inside function(Data){ and that the error starts at $.each I believe
[jQuery] Re: G is undefined
Wow, is posting the same thing every 3 mins to bump your topic annoying Anyways, your results wrapped in [ ] signifies an Array, not a JSON object hence .getJSON has no idea what to do with it On Jun 29, 11:53 am, expresso dschin...@gmail.com wrote: So is this valid JSON that jQuery can parse? or do I need an initial level such as Images: [{Images : [{ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpg; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http://www.xxx.com/image/4852.jpg; alt=quot;quot;gt;} ]] On Jun 29, 10:37 am, expresso dschin...@gmail.com wrote: Ok, figured out that data.items is undefined. Not sure why because here's the json my url returns: [{ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpg; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http://www.xxx.com/image/4852.jpgalt=quot;quot;gt;}] On Jun 29, 10:33 am, expresso dschin...@gmail.com wrote: I get the following error: G is undefined init()()jquery-12.min.js (line 12) (?)()()Carousel.aspx (line 30) I()jquery-12.min.js (line 19) F()()jquery-12.min.js (line 19) [Break on this error] (function(){var l=this,g,y=l.jQuery,p=l.each (function(){o.dequeue(this,E)})}}); in jquery-1.3.2.min.js when I call this method of mine: $.getJSON(http://localhost:59396/xxx/xxxHandler.ashx? action=xxxjson, function(Data) { $.each(Data.items, function(i, item) { alert('got here'); carousel.add(i, mycarousel_decodeEntities(item.ImageTag)); if (i == 3) return false; }); }); I know I can get inside function(Data){ and that the error starts at $.each I believe
[jQuery] Re: G is undefined
yea, refreshing the page posts again, very annoying On Jun 29, 10:58 am, MorningZ morni...@gmail.com wrote: Wow, is posting the same thing every 3 mins to bump your topic annoying Anyways, your results wrapped in [ ] signifies an Array, not a JSON object hence .getJSON has no idea what to do with it On Jun 29, 11:53 am, expresso dschin...@gmail.com wrote: So is this valid JSON that jQuery can parse? or do I need an initial level such as Images: [{Images : [{ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpg; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http://www.xxx.com/image/4852.jpg; alt=quot;quot;gt;} ]] On Jun 29, 10:37 am, expresso dschin...@gmail.com wrote: Ok, figured out that data.items is undefined. Not sure why because here's the json my url returns: [{ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpg; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http://www.xxx.com/image/4852.jpgalt=quot;quot;gt;}] On Jun 29, 10:33 am, expresso dschin...@gmail.com wrote: I get the following error: G is undefined init()()jquery-12.min.js (line 12) (?)()()Carousel.aspx (line 30) I()jquery-12.min.js (line 19) F()()jquery-12.min.js (line 19) [Break on this error] (function(){var l=this,g,y=l.jQuery,p=l.each (function(){o.dequeue(this,E)})}}); in jquery-1.3.2.min.js when I call this method of mine: $.getJSON(http://localhost:59396/xxx/xxxHandler.ashx? action=xxxjson, function(Data) { $.each(Data.items, function(i, item) { alert('got here'); carousel.add(i, mycarousel_decodeEntities(item.ImageTag)); if (i == 3) return false; }); }); I know I can get inside function(Data){ and that the error starts at $.each I believe
[jQuery] Re: G is undefined
this is how I'm sending the JSON, so it adds [ ] http://weblogs.asp.net/scottgu/archive/2007/10/01/tip-trick-building-a-tojson-extension-method-using-net-3-5.aspx On Jun 29, 10:58 am, MorningZ morni...@gmail.com wrote: Wow, is posting the same thing every 3 mins to bump your topic annoying Anyways, your results wrapped in [ ] signifies an Array, not a JSON object hence .getJSON has no idea what to do with it On Jun 29, 11:53 am, expresso dschin...@gmail.com wrote: So is this valid JSON that jQuery can parse? or do I need an initial level such as Images: [{Images : [{ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpg; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http://www.xxx.com/image/4852.jpg; alt=quot;quot;gt;} ]] On Jun 29, 10:37 am, expresso dschin...@gmail.com wrote: Ok, figured out that data.items is undefined. Not sure why because here's the json my url returns: [{ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpg; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http://www.xxx.com/image/4852.jpgalt=quot;quot;gt;}] On Jun 29, 10:33 am, expresso dschin...@gmail.com wrote: I get the following error: G is undefined init()()jquery-12.min.js (line 12) (?)()()Carousel.aspx (line 30) I()jquery-12.min.js (line 19) F()()jquery-12.min.js (line 19) [Break on this error] (function(){var l=this,g,y=l.jQuery,p=l.each (function(){o.dequeue(this,E)})}}); in jquery-1.3.2.min.js when I call this method of mine: $.getJSON(http://localhost:59396/xxx/xxxHandler.ashx? action=xxxjson, function(Data) { $.each(Data.items, function(i, item) { alert('got here'); carousel.add(i, mycarousel_decodeEntities(item.ImageTag)); if (i == 3) return false; }); }); I know I can get inside function(Data){ and that the error starts at $.each I believe
[jQuery] Re: G is undefined
http://en.wikipedia.org/wiki/JSON will show you what it should look like... notice the outside symbols are { ... }, not [ ] again, you should look at this if you are working with .NET and JSON, it really takes all this guess work from the equation: http://james.newtonking.com/pages/json-net.aspx On Jun 29, 12:01 pm, expresso dschin...@gmail.com wrote: Ok, so what should it be wrapped in or how should I reformat this? On Jun 29, 10:58 am, MorningZ morni...@gmail.com wrote: Wow, is posting the same thing every 3 mins to bump your topic annoying Anyways, your results wrapped in [ ] signifies an Array, not a JSON object hence .getJSON has no idea what to do with it On Jun 29, 11:53 am, expresso dschin...@gmail.com wrote: So is this valid JSON that jQuery can parse? or do I need an initial level such as Images: [{Images : [{ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpg; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http://www.xxx.com/image/4852.jpg; alt=quot;quot;gt;} ]] On Jun 29, 10:37 am, expresso dschin...@gmail.com wrote: Ok, figured out that data.items is undefined. Not sure why because here's the json my url returns: [{ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpg; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http://www.xxx.com/image/4852.jpgalt=quot;quot;gt;}] On Jun 29, 10:33 am, expresso dschin...@gmail.com wrote: I get the following error: G is undefined init()()jquery-12.min.js (line 12) (?)()()Carousel.aspx (line 30) I()jquery-12.min.js (line 19) F()()jquery-12.min.js (line 19) [Break on this error] (function(){var l=this,g,y=l.jQuery,p=l.each (function(){o.dequeue(this,E)})}}); in jquery-1.3.2.min.js when I call this method of mine: $.getJSON(http://localhost:59396/xxx/xxxHandler.ashx? action=xxxjson, function(Data) { $.each(Data.items, function(i, item) { alert('got here'); carousel.add(i, mycarousel_decodeEntities(item.ImageTag)); if (i == 3) return false; }); }); I know I can get inside function(Data){ and that the error starts at $.each I believe
[jQuery] Re: G is undefined
Thanks I've seen this but would rather stay away from any libraries right now. So basically yea, should be {} I just wonder why the ASP.NET 3.5 JavascriptSerializer class doesn't produce the right output. On Jun 29, 11:03 am, MorningZ morni...@gmail.com wrote: http://en.wikipedia.org/wiki/JSON will show you what it should look like... notice the outside symbols are { ... }, not [ ] again, you should look at this if you are working with .NET and JSON, it really takes all this guess work from the equation: http://james.newtonking.com/pages/json-net.aspx On Jun 29, 12:01 pm, expresso dschin...@gmail.com wrote: Ok, so what should it be wrapped in or how should I reformat this? On Jun 29, 10:58 am, MorningZ morni...@gmail.com wrote: Wow, is posting the same thing every 3 mins to bump your topic annoying Anyways, your results wrapped in [ ] signifies an Array, not a JSON object hence .getJSON has no idea what to do with it On Jun 29, 11:53 am, expresso dschin...@gmail.com wrote: So is this valid JSON that jQuery can parse? or do I need an initial level such as Images: [{Images : [{ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpg; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http://www.xxx.com/image/4852.jpg; alt=quot;quot;gt;} ]] On Jun 29, 10:37 am, expresso dschin...@gmail.com wrote: Ok, figured out that data.items is undefined. Not sure why because here's the json my url returns: [{ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpg; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http://www.xxx.com/image/4852.jpgalt=quot;quot;gt;}] On Jun 29, 10:33 am, expresso dschin...@gmail.com wrote: I get the following error: G is undefined init()()jquery-12.min.js (line 12) (?)()()Carousel.aspx (line 30) I()jquery-12.min.js (line 19) F()()jquery-12.min.js (line 19) [Break on this error] (function(){var l=this,g,y=l.jQuery,p=l.each (function(){o.dequeue(this,E)})}}); in jquery-1.3.2.min.js when I call this method of mine: $.getJSON(http://localhost:59396/xxx/xxxHandler.ashx? action=xxxjson, function(Data) { $.each(Data.items, function(i, item) { alert('got here'); carousel.add(i, mycarousel_decodeEntities(item.ImageTag)); if (i == 3) return false; }); }); I know I can get inside function(Data){ and that the error starts at $.each I believe
[jQuery] Re: G is undefined
some tells me that my original JSON is totally valid with the [ and ] On Jun 29, 11:03 am, MorningZ morni...@gmail.com wrote: http://en.wikipedia.org/wiki/JSON will show you what it should look like... notice the outside symbols are { ... }, not [ ] again, you should look at this if you are working with .NET and JSON, it really takes all this guess work from the equation: http://james.newtonking.com/pages/json-net.aspx On Jun 29, 12:01 pm, expresso dschin...@gmail.com wrote: Ok, so what should it be wrapped in or how should I reformat this? On Jun 29, 10:58 am, MorningZ morni...@gmail.com wrote: Wow, is posting the same thing every 3 mins to bump your topic annoying Anyways, your results wrapped in [ ] signifies an Array, not a JSON object hence .getJSON has no idea what to do with it On Jun 29, 11:53 am, expresso dschin...@gmail.com wrote: So is this valid JSON that jQuery can parse? or do I need an initial level such as Images: [{Images : [{ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpg; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http://www.xxx.com/image/4852.jpg; alt=quot;quot;gt;} ]] On Jun 29, 10:37 am, expresso dschin...@gmail.com wrote: Ok, figured out that data.items is undefined. Not sure why because here's the json my url returns: [{ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpg; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http://www.xxx.com/image/4852.jpgalt=quot;quot;gt;}] On Jun 29, 10:33 am, expresso dschin...@gmail.com wrote: I get the following error: G is undefined init()()jquery-12.min.js (line 12) (?)()()Carousel.aspx (line 30) I()jquery-12.min.js (line 19) F()()jquery-12.min.js (line 19) [Break on this error] (function(){var l=this,g,y=l.jQuery,p=l.each (function(){o.dequeue(this,E)})}}); in jquery-1.3.2.min.js when I call this method of mine: $.getJSON(http://localhost:59396/xxx/xxxHandler.ashx? action=xxxjson, function(Data) { $.each(Data.items, function(i, item) { alert('got here'); carousel.add(i, mycarousel_decodeEntities(item.ImageTag)); if (i == 3) return false; }); }); I know I can get inside function(Data){ and that the error starts at $.each I believe
[jQuery] Re: G is undefined
I even sent a test string without the [ ] and I still get 'undefined' for my alert here: function mycarousel_itemLoadCallback(carousel, state) { // Only load items if they don't already exist if (carousel.has(carousel.first, carousel.last)) { return; } $.getJSON(http://localhost:59396/sss/CHandler.ashx? action=productsjson, function(data) { alert(data.items); $.each(data.items, function(i, item) { carousel.add(i, mycarousel_decodeEntities(item)); if (i == 3) return false; }); }); }; the JSON in this case was: {ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpgquot; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http:// www.xxx.com/cat_image/485.jpgquot; alt=quot;quot;gt;} so same deal here. I'm stuck. On Jun 29, 11:03 am, MorningZ morni...@gmail.com wrote: http://en.wikipedia.org/wiki/JSON will show you what it should look like... notice the outside symbols are { ... }, not [ ] again, you should look at this if you are working with .NET and JSON, it really takes all this guess work from the equation: http://james.newtonking.com/pages/json-net.aspx On Jun 29, 12:01 pm, expresso dschin...@gmail.com wrote: Ok, so what should it be wrapped in or how should I reformat this? On Jun 29, 10:58 am, MorningZ morni...@gmail.com wrote: Wow, is posting the same thing every 3 mins to bump your topic annoying Anyways, your results wrapped in [ ] signifies an Array, not a JSON object hence .getJSON has no idea what to do with it On Jun 29, 11:53 am, expresso dschin...@gmail.com wrote: So is this valid JSON that jQuery can parse? or do I need an initial level such as Images: [{Images : [{ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpg; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http://www.xxx.com/image/4852.jpg; alt=quot;quot;gt;} ]] On Jun 29, 10:37 am, expresso dschin...@gmail.com wrote: Ok, figured out that data.items is undefined. Not sure why because here's the json my url returns: [{ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpg; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http://www.xxx.com/image/4852.jpgalt=quot;quot;gt;}] On Jun 29, 10:33 am, expresso dschin...@gmail.com wrote: I get the following error: G is undefined init()()jquery-12.min.js (line 12) (?)()()Carousel.aspx (line 30) I()jquery-12.min.js (line 19) F()()jquery-12.min.js (line 19) [Break on this error] (function(){var l=this,g,y=l.jQuery,p=l.each (function(){o.dequeue(this,E)})}}); in jquery-1.3.2.min.js when I call this method of mine: $.getJSON(http://localhost:59396/xxx/xxxHandler.ashx? action=xxxjson, function(Data) { $.each(Data.items, function(i, item) { alert('got here'); carousel.add(i, mycarousel_decodeEntities(item.ImageTag)); if (i == 3) return false; }); }); I know I can get inside function(Data){ and that the error starts at $.each I believe
[jQuery] Re: G is undefined
That's right, your JSON is perfectly valid. You can test it at: www.jsonlint.org Here's the formatted output from that site, with the image tags elided for clarity, and comments added showing how you'd access each part of it directly in JavaScript: // Data [ // Data[0] { // Data[0].ImageTag ImageTag: ... }, // Data[1] { // Data[1].ImageTag ImageTag: ... } ] As you can see, what you have is an array of two elements. Each of those elements is an object with a single property named ImageTag with a string value. Now back to your code. This is where it goes wrong: $.each(Data.items, function(i, item) {...}); Data here is the JSON data, and you're trying to get its items property and use it as an array. But there is no items property - Data itself is the array, so you'd use it directly: $.each(Data, function(i, item) {...}); JSON that would work with your original code using Data.items would look like this: // Data { // Data.items items: [ // Data.items[0] { // Data.items[0].ImageTag ImageTag: ... }, // Data.items[1] { // Data.items[1].ImageTag ImageTag: ... } ] } BTW, I suggest using variable names that begin with lower case. The upper case first letter makes people think it's the name of a constructor. -Mike From: expresso some tells me that my original JSON is totally valid with the [ and ] On Jun 29, 11:03 am, MorningZ morni...@gmail.com wrote: http://en.wikipedia.org/wiki/JSON will show you what it should look like... notice the outside symbols are { ... }, not [ ] again, you should look at this if you are working with .NET and JSON, it really takes all this guess work from the equation: http://james.newtonking.com/pages/json-net.aspx On Jun 29, 12:01 pm, expresso dschin...@gmail.com wrote: Ok, so what should it be wrapped in or how should I reformat this? On Jun 29, 10:58 am, MorningZ morni...@gmail.com wrote: Wow, is posting the same thing every 3 mins to bump your topic annoying Anyways, your results wrapped in [ ] signifies an Array, not a JSON object hence .getJSON has no idea what to do with it On Jun 29, 11:53 am, expresso dschin...@gmail.com wrote: So is this valid JSON that jQuery can parse? or do I need an initial level such as Images: [{Images : [{ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpg; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http://www.xxx.com/image/4852.jpg; alt=quot;quot;gt;} ]] On Jun 29, 10:37 am, expresso dschin...@gmail.com wrote: Ok, figured out that data.items is undefined. Not sure why because here's the json my url returns: [{ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpg; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http://www.xxx.com/image/4852.jpgalt=quot;quot;g t;}] On Jun 29, 10:33 am, expresso dschin...@gmail.com wrote: I get the following error: G is undefined init()()jquery-12.min.js (line 12) (?)()()Carousel.aspx (line 30) I()jquery-12.min.js (line 19) F()()jquery-12.min.js (line 19) [Break on this error] (function(){var l=this,g,y=l.jQuery,p=l.each (function(){o.dequeue(this,E)})}}); in jquery-1.3.2.min.js when I call this method of mine: $.getJSON(http://localhost:59396/xxx/xxxHandler.ashx? action=xxxjson, function(Data) { $.each(Data.items, function(i, item) { alert('got here'); carousel.add(i, mycarousel_decodeEntities(item.ImageTag)); if (i == 3) return false; }); }); I know I can get inside function(Data){ and that the error starts at $.each I believe
[jQuery] Re: G is undefined
Mike thanks a lot. That is so weird. I got some ideas from http://docs.jquery.com/GetJSON and as you can see from the example it's using data.items. it's working now. I just wonder why the jQuery example is using data.items On Jun 29, 12:19 pm, Michael Geary m...@mg.to wrote: That's right, your JSON is perfectly valid. You can test it at: www.jsonlint.org Here's the formatted output from that site, with the image tags elided for clarity, and comments added showing how you'd access each part of it directly in JavaScript: // Data [ // Data[0] { // Data[0].ImageTag ImageTag: ... }, // Data[1] { // Data[1].ImageTag ImageTag: ... } ] As you can see, what you have is an array of two elements. Each of those elements is an object with a single property named ImageTag with a string value. Now back to your code. This is where it goes wrong: $.each(Data.items, function(i, item) {...}); Data here is the JSON data, and you're trying to get its items property and use it as an array. But there is no items property - Data itself is the array, so you'd use it directly: $.each(Data, function(i, item) {...}); JSON that would work with your original code using Data.items would look like this: // Data { // Data.items items: [ // Data.items[0] { // Data.items[0].ImageTag ImageTag: ... }, // Data.items[1] { // Data.items[1].ImageTag ImageTag: ... } ] } BTW, I suggest using variable names that begin with lower case. The upper case first letter makes people think it's the name of a constructor. -Mike From: expresso some tells me that my original JSON is totally valid with the [ and ] On Jun 29, 11:03 am, MorningZ morni...@gmail.com wrote: http://en.wikipedia.org/wiki/JSON will show you what it should look like... notice the outside symbols are { ... }, not [ ] again, you should look at this if you are working with .NET and JSON, it really takes all this guess work from the equation: http://james.newtonking.com/pages/json-net.aspx On Jun 29, 12:01 pm, expresso dschin...@gmail.com wrote: Ok, so what should it be wrapped in or how should I reformat this? On Jun 29, 10:58 am, MorningZ morni...@gmail.com wrote: Wow, is posting the same thing every 3 mins to bump your topic annoying Anyways, your results wrapped in [ ] signifies an Array, not a JSON object hence .getJSON has no idea what to do with it On Jun 29, 11:53 am, expresso dschin...@gmail.com wrote: So is this valid JSON that jQuery can parse? or do I need an initial level such as Images: [{Images : [{ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpg; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http://www.xxx.com/image/4852.jpg; alt=quot;quot;gt;} ]] On Jun 29, 10:37 am, expresso dschin...@gmail.com wrote: Ok, figured out that data.items is undefined. Not sure why because here's the json my url returns: [{ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpg; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http://www.xxx.com/image/4852.jpgalt=quot;quot;g t;}] On Jun 29, 10:33 am, expresso dschin...@gmail.com wrote: I get the following error: G is undefined init()()jquery-12.min.js (line 12) (?)()()Carousel.aspx (line 30) I()jquery-12.min.js (line 19) F()()jquery-12.min.js (line 19) [Break on this error] (function(){var l=this,g,y=l.jQuery,p=l.each (function(){o.dequeue(this,E)})}}); in jquery-1.3.2.min.js when I call this method of mine: $.getJSON(http://localhost:59396/xxx/xxxHandler.ashx? action=xxxjson, function(Data) { $.each(Data.items, function(i, item) { alert('got here'); carousel.add(i, mycarousel_decodeEntities(item.ImageTag)); if (i == 3) return false; }); }); I know I can get inside function(Data){ and that the error starts at $.each I believe
[jQuery] Re: G is undefined
I understand. Thanks for the explanation. On Jun 29, 12:19 pm, Michael Geary m...@mg.to wrote: That's right, your JSON is perfectly valid. You can test it at: www.jsonlint.org Here's the formatted output from that site, with the image tags elided for clarity, and comments added showing how you'd access each part of it directly in JavaScript: // Data [ // Data[0] { // Data[0].ImageTag ImageTag: ... }, // Data[1] { // Data[1].ImageTag ImageTag: ... } ] As you can see, what you have is an array of two elements. Each of those elements is an object with a single property named ImageTag with a string value. Now back to your code. This is where it goes wrong: $.each(Data.items, function(i, item) {...}); Data here is the JSON data, and you're trying to get its items property and use it as an array. But there is no items property - Data itself is the array, so you'd use it directly: $.each(Data, function(i, item) {...}); JSON that would work with your original code using Data.items would look like this: // Data { // Data.items items: [ // Data.items[0] { // Data.items[0].ImageTag ImageTag: ... }, // Data.items[1] { // Data.items[1].ImageTag ImageTag: ... } ] } BTW, I suggest using variable names that begin with lower case. The upper case first letter makes people think it's the name of a constructor. -Mike From: expresso some tells me that my original JSON is totally valid with the [ and ] On Jun 29, 11:03 am, MorningZ morni...@gmail.com wrote: http://en.wikipedia.org/wiki/JSON will show you what it should look like... notice the outside symbols are { ... }, not [ ] again, you should look at this if you are working with .NET and JSON, it really takes all this guess work from the equation: http://james.newtonking.com/pages/json-net.aspx On Jun 29, 12:01 pm, expresso dschin...@gmail.com wrote: Ok, so what should it be wrapped in or how should I reformat this? On Jun 29, 10:58 am, MorningZ morni...@gmail.com wrote: Wow, is posting the same thing every 3 mins to bump your topic annoying Anyways, your results wrapped in [ ] signifies an Array, not a JSON object hence .getJSON has no idea what to do with it On Jun 29, 11:53 am, expresso dschin...@gmail.com wrote: So is this valid JSON that jQuery can parse? or do I need an initial level such as Images: [{Images : [{ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpg; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http://www.xxx.com/image/4852.jpg; alt=quot;quot;gt;} ]] On Jun 29, 10:37 am, expresso dschin...@gmail.com wrote: Ok, figured out that data.items is undefined. Not sure why because here's the json my url returns: [{ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpg; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http://www.xxx.com/image/4852.jpgalt=quot;quot;g t;}] On Jun 29, 10:33 am, expresso dschin...@gmail.com wrote: I get the following error: G is undefined init()()jquery-12.min.js (line 12) (?)()()Carousel.aspx (line 30) I()jquery-12.min.js (line 19) F()()jquery-12.min.js (line 19) [Break on this error] (function(){var l=this,g,y=l.jQuery,p=l.each (function(){o.dequeue(this,E)})}}); in jquery-1.3.2.min.js when I call this method of mine: $.getJSON(http://localhost:59396/xxx/xxxHandler.ashx? action=xxxjson, function(Data) { $.each(Data.items, function(i, item) { alert('got here'); carousel.add(i, mycarousel_decodeEntities(item.ImageTag)); if (i == 3) return false; }); }); I know I can get inside function(Data){ and that the error starts at $.each I believe
[jQuery] Re: G is undefined
In addition to www.jsonlint.org, since you're developing on Windows, head over here right now and get the Fiddler debugging proxy server: http://www.fiddler2.com/ Then, go to the Extensions page: http://www.fiddler2.com/Fiddler2/extensions.asp At the very least get the JSON Viewer (at the bottom of the page, misnamed as JSON Inspector), and check out some of the other extensions too. The syntax highlighting package and JavaScript formatter are especially useful. The JSON Viewer will both install into Fiddler, so you can view JSON data directly in Fiddler, and you can also run it as a standalone app: Copy and paste your JSON text into the Text tab and then switch to the Viewer tab to inspect it. What the JSON Viewer does that's nice is it shows you the JSON data in a tree structure so you can see how you'd drill down into it with JavaScript code. -Mike From: Michael Geary You can test [your JSON code] at: www.jsonlint.org
[jQuery] Re: G is undefined
The jQuery example is using data.items because the JSON object it is retrieving is different from yours. Its JSON object is coming from the flickr API. --Karl Karl Swedberg www.englishrules.com www.learningjquery.com On Jun 29, 2009, at 1:25 PM, expresso wrote: Mike thanks a lot. That is so weird. I got some ideas from http://docs.jquery.com/GetJSON and as you can see from the example it's using data.items. it's working now. I just wonder why the jQuery example is using data.items On Jun 29, 12:19 pm, Michael Geary m...@mg.to wrote: That's right, your JSON is perfectly valid. You can test it at: www.jsonlint.org Here's the formatted output from that site, with the image tags elided for clarity, and comments added showing how you'd access each part of it directly in JavaScript: // Data [ // Data[0] { // Data[0].ImageTag ImageTag: ... }, // Data[1] { // Data[1].ImageTag ImageTag: ... } ] As you can see, what you have is an array of two elements. Each of those elements is an object with a single property named ImageTag with a string value. Now back to your code. This is where it goes wrong: $.each(Data.items, function(i, item) {...}); Data here is the JSON data, and you're trying to get its items property and use it as an array. But there is no items property - Data itself is the array, so you'd use it directly: $.each(Data, function(i, item) {...}); JSON that would work with your original code using Data.items would look like this: // Data { // Data.items items: [ // Data.items[0] { // Data.items[0].ImageTag ImageTag: ... }, // Data.items[1] { // Data.items[1].ImageTag ImageTag: ... } ] } BTW, I suggest using variable names that begin with lower case. The upper case first letter makes people think it's the name of a constructor. -Mike From: expresso some tells me that my original JSON is totally valid with the [ and ] On Jun 29, 11:03 am, MorningZ morni...@gmail.com wrote: http://en.wikipedia.org/wiki/JSON will show you what it should look like... notice the outside symbols are { ... }, not [ ] again, you should look at this if you are working with .NET and JSON, it really takes all this guess work from the equation: http://james.newtonking.com/pages/json-net.aspx On Jun 29, 12:01 pm, expresso dschin...@gmail.com wrote: Ok, so what should it be wrapped in or how should I reformat this? On Jun 29, 10:58 am, MorningZ morni...@gmail.com wrote: Wow, is posting the same thing every 3 mins to bump your topic annoying Anyways, your results wrapped in [ ] signifies an Array, not a JSON object hence .getJSON has no idea what to do with it On Jun 29, 11:53 am, expresso dschin...@gmail.com wrote: So is this valid JSON that jQuery can parse? or do I need an initial level such as Images: [{Images : [{ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpg; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http://www.xxx.com/image/4852.jpg; alt=quot;quot;gt;} ]] On Jun 29, 10:37 am, expresso dschin...@gmail.com wrote: Ok, figured out that data.items is undefined. Not sure why because here's the json my url returns: [{ImageTag:lt;img src=quot;http://www.xxx.com/image/473.jpg; alt=quot;quot;gt;},{ImageTag:lt;img src=quot;http://www.xxx.com/image/4852.jpgalt=quot;quot;g t;}] On Jun 29, 10:33 am, expresso dschin...@gmail.com wrote: I get the following error: G is undefined init()()jquery-12.min.js (line 12) (?)()()Carousel.aspx (line 30) I()jquery-12.min.js (line 19) F()()jquery-12.min.js (line 19) [Break on this error] (function(){var l=this,g,y=l.jQuery,p=l.each (function(){o.dequeue(this,E)})}}); in jquery-1.3.2.min.js when I call this method of mine: $.getJSON(http://localhost:59396/xxx/xxxHandler.ashx? action=xxxjson, function(Data) { $.each(Data.items, function(i, item) { alert('got here'); carousel.add(i, mycarousel_decodeEntities(item.ImageTag)); if (i == 3) return false; }); }); I know I can get inside function(Data){ and that the error starts at $.each I believe
[jQuery] Re: G is undefined
The jQuery example uses data.items because the JSON data it fetches is an object with an items property. Load the sample URL in your browser and look at the data: http://api.flickr.com/services/feeds/photos_public.gne?tags=cattagmode=any format=json http://api.flickr.com/services/feeds/photos_public.gne?tags=cattagmode=any; format=json If you remove the jsonFlickrFeed() JSONP wrapper, then the data in skeletal form looks like: { title: Recent Uploads tagged cat, link: http://www.flickr.com/photos/tags/cat/;, description: , modified: 2009-06-29T17:21:37Z, generator: http://www.flickr.com/;, items: [ { title: Metzler Ortloff #137X, link: http://www.flickr.com/photos/31042...@n02/3671772469/;, media: { m: http://farm4.static.flickr.com/3613/3671772469_431f0c6df0_m.jpg; }, date_taken: 2009-06-29T10:21:37-08:00, description: p...\/p, published: 2009-06-29T17:21:37Z, author: nob...@flickr.com (metzlerortloff.cats), author_id: 31042...@n02, tags: cat ilmenau metzler ortloff }, { // ...another item here, etc... } ] } As you can see, here the outermost part of the JSON is an object enclosed by the {}. This object has an items property, which is the array of data for each of the Flickr images. So, if you fetch this JSON object into a variable named data, then data.items will be that items array. If you paste the Flickr response into the JSON viewer that I mentioned in my other message, it will show you a nicely formatted tree structure for the data. Paste it into the Text tab and you will see an error message at the bottom because of the JSONP wrapper. Use the Strip to {} button at the top to automatically strip out that wrapper. Then click the Viewer tab to see the structure of the data. -Mike From: expresso Mike thanks a lot. That is so weird. I got some ideas from http://docs.jquery.com/GetJSON http://docs.jquery.com/GetJSON and as you can see from the example it's using data.items. it's working now. I just wonder why the jQuery example is using data.items On Jun 29, 12:19 pm, Michael Geary m...@mg.to wrote: That's right, your JSON is perfectly valid. You can test it at: www.jsonlint.org Here's the formatted output from that site, with the image tags elided for clarity, and comments added showing how you'd access each part of it directly in JavaScript: // Data [ // Data[0] { // Data[0].ImageTag ImageTag: ... }, // Data[1] { // Data[1].ImageTag ImageTag: ... } ] As you can see, what you have is an array of two elements. Each of those elements is an object with a single property named ImageTag with a string value. Now back to your code. This is where it goes wrong: $.each(Data.items, function(i, item) {...}); Data here is the JSON data, and you're trying to get its items property and use it as an array. But there is no items property - Data itself is the array, so you'd use it directly: $.each(Data, function(i, item) {...}); JSON that would work with your original code using Data.items would look like this: // Data { // Data.items items: [ // Data.items[0] { // Data.items[0].ImageTag ImageTag: ... }, // Data.items[1] { // Data.items[1].ImageTag ImageTag: ... } ] } BTW, I suggest using variable names that begin with lower case. The upper case first letter makes people think it's the name of a constructor. -Mike From: expresso some tells me that my original JSON is totally valid with the [ and ] On Jun 29, 11:03 am, MorningZ morni...@gmail.com wrote: http://en.wikipedia.org/wiki/JSON http://en.wikipedia.org/wiki/JSON will show you what it should look like... notice the outside symbols are { ... }, not [ ] again, you should look at this if you are working with .NET and JSON, it really takes all this guess work from the equation: http://james.newtonking.com/pages/json-net.aspx http://james.newtonking.com/pages/json-net.aspx On Jun 29, 12:01 pm, expresso dschin...@gmail.com wrote: Ok, so what should it be wrapped in or how should I reformat this? On Jun 29, 10:58 am, MorningZ morni...@gmail.com wrote: Wow, is posting the same thing every 3 mins to bump your topic annoying Anyways, your results wrapped in [ ] signifies an Array, not a JSON object hence .getJSON has no
[jQuery] Re: G is undefined
Thanks all. On Jun 29, 1:12 pm, Michael Geary m...@mg.to wrote: The jQuery example uses data.items because the JSON data it fetches is an object with an items property. Load the sample URL in your browser and look at the data: http://api.flickr.com/services/feeds/photos_public.gne?tags=cattagmo... format=jsonhttp://api.flickr.com/services/feeds/photos_public.gne?tags=cattagmo... format=json If you remove the jsonFlickrFeed() JSONP wrapper, then the data in skeletal form looks like: { title: Recent Uploads tagged cat, link: http://www.flickr.com/photos/tags/cat/;, description: , modified: 2009-06-29T17:21:37Z, generator: http://www.flickr.com/;, items: [ { title: Metzler Ortloff #137X, link: http://www.flickr.com/photos/31042...@n02/3671772469/;, media: { m: http://farm4.static.flickr.com/3613/3671772469_431f0c6df0_m.jpg; }, date_taken: 2009-06-29T10:21:37-08:00, description: p...\/p, published: 2009-06-29T17:21:37Z, author: nob...@flickr.com (metzlerortloff.cats), author_id: 31042...@n02, tags: cat ilmenau metzler ortloff }, { // ...another item here, etc... } ] } As you can see, here the outermost part of the JSON is an object enclosed by the {}. This object has an items property, which is the array of data for each of the Flickr images. So, if you fetch this JSON object into a variable named data, then data.items will be that items array. If you paste the Flickr response into the JSON viewer that I mentioned in my other message, it will show you a nicely formatted tree structure for the data. Paste it into the Text tab and you will see an error message at the bottom because of the JSONP wrapper. Use the Strip to {} button at the top to automatically strip out that wrapper. Then click the Viewer tab to see the structure of the data. -Mike From: expresso Mike thanks a lot. That is so weird. I got some ideas from http://docs.jquery.com/GetJSONhttp://docs.jquery.com/GetJSONand as you can see from the example it's using data.items. it's working now. I just wonder why the jQuery example is using data.items On Jun 29, 12:19 pm, Michael Geary m...@mg.to wrote: That's right, your JSON is perfectly valid. You can test it at: www.jsonlint.org Here's the formatted output from that site, with the image tags elided for clarity, and comments added showing how you'd access each part of it directly in JavaScript: // Data [ // Data[0] { // Data[0].ImageTag ImageTag: ... }, // Data[1] { // Data[1].ImageTag ImageTag: ... } ] As you can see, what you have is an array of two elements. Each of those elements is an object with a single property named ImageTag with a string value. Now back to your code. This is where it goes wrong: $.each(Data.items, function(i, item) {...}); Data here is the JSON data, and you're trying to get its items property and use it as an array. But there is no items property - Data itself is the array, so you'd use it directly: $.each(Data, function(i, item) {...}); JSON that would work with your original code using Data.items would look like this: // Data { // Data.items items: [ // Data.items[0] { // Data.items[0].ImageTag ImageTag: ... }, // Data.items[1] { // Data.items[1].ImageTag ImageTag: ... } ] } BTW, I suggest using variable names that begin with lower case. The upper case first letter makes people think it's the name of a constructor. -Mike From: expresso some tells me that my original JSON is totally valid with the [ and ] On Jun 29, 11:03 am, MorningZ morni...@gmail.com wrote: http://en.wikipedia.org/wiki/JSON http://en.wikipedia.org/wiki/JSON will show you what it should look like... notice the outside symbols are { ... }, not [ ] again, you should look at this if you are working with .NET and JSON, it really takes all this guess work from the equation: http://james.newtonking.com/pages/json-net.aspx http://james.newtonking.com/pages/json-net.aspx On Jun 29, 12:01 pm, expresso dschin...@gmail.com wrote: Ok, so what should it be wrapped in or how should I reformat this? On Jun 29, 10:58 am, MorningZ morni...@gmail.com wrote: Wow, is posting the same thing every 3 mins to