开发者

What JSON does this CF code return?

开发者 https://www.devze.com 2023-01-05 10:43 出处:网络
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

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 开发者_JAVA技巧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!!


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号