views:

66

answers:

2

Trying to implement the excellent jQuery bidirectional infite scroll as explained here:

http://www.bennadel.com/blog/1803-Creating-A-Bidirectional-Infinite-Scroll-Page-With-jQuery-And-ColdFusion.htm

For the server-side, which returns JSON, the example is in ColdFusion. Trying to implement it in PHP.

I need to find out what the format of the JSON is.

RIght now, I am returning

[{"src":"https:\/\/s3.amazonaws.com\/gbblr_2\/100\/IMG_1400 - original.jpg","offset":"5"},{"src":"https:\/\/s3.amazonaws.com\/gbblr_2\/100\/IMG_1399 - original.jpg","offset":6},{"src":"https:\/\/s3.amazonaws.com\/gbblr_2\/100\/IMG_1398 - original.jpg","offset":7}]

which doesn't work, in the html that is generated it shows "UNDEFINED" for both the src and the offset variables.

So my question: what kind of JSON does that coldfusion code generate? What is the format of JSON that I need to return.

Thanks for any tips!!

A: 

Looks like the JSON you're creating should be equivalent to his. He is creating an array of structures; where each structure contains the keys "src" and "offset".

He is converting to base64 and binary for streaming purposes, but I don't know how that would work -- or if it would be required -- for a php implementation.

I would use Firebug to figure out exactly where in your JavaScript the error is being thrown. That will tell you more about what exactly the problem is.

Adam Tuttle
Thanks. There's no error being thrown, it just gets the variables from the json and puts them in the template as "UNDEFINED" (instead of as their actual values).
then seems like there's something wrong in your JS, post them up!
Henry
+2  A: 

CF's JSON mentioned in Ben's post is similar to this:

[{"SRC":"http:\/\/example.com\/public","OFFSET":3.0},{"SRC":"http:\/\/example.com\/public","OFFSET":3.0}] 

I'd try to check key names first. Yes, CF makes them uppercase, and JS doesn't like it sometimes. Check his function applyListItems() and check if RegExp finds something or not.

If this doesn't help little Firebug line debugging and console.log will do the trick I guess.

zarko.susnjar
AWESOME, changing src and offset to SRC and OFFSET all caps fixed the problem. Who'da thunk it. Thanks, just saved me another day of trying to find the problem :)