rsanchez / json

Output ExpressionEngine data in JSON format.
http://devot-ee.com/add-ons/json/
101 stars 234 forks source link

JSON Queries #16

Closed nate8684 closed 12 years ago

nate8684 commented 12 years ago

Tried using your method here of pulling JSON data from your plugin on EE. In the console this is what always shows up:

GET http://www.lcbcchurch.com/mobileJSON/homeslideshow/results?_=1329339833378 404 (Not Found) f.ajaxTransport.sendjquery.js:4 f.extend.ajaxjquery.js:4 (anonymous function)

I think i'm following your directions accurately but things don't seem to be working. Any thought? Here is my ee code:

{exp:json:entries channel="slideshow" jsonp="yes" callback="{segment_3}" content_type="application/javascript"}

and my html/js:

<!DOCTYPE html>
<html>
    <head>
        <title>PhoneGap Ajax Sample</title>
        <script type="text/javascript" src="phonegap.js"></script>
        <script type="text/javascript" src="js/jquery.js"></script>
        <script type="text/javascript">
            $.ajax({
                       url: "http://www.lcbcchurch.com/mobileJSON/homeslideshow/results",
                       dataType: "jsonp",
                       jsonp: false
                       });
                function results(data) {
                    console.log(data);
                }

            </script>

    </head>
    <body>
        <div id="main">

        </div>
    </body>
</html>

Also, if you go directly to "http://www.lcbcchurch.com/mobileJSON/homeslideshow/results" I can see the output.

nate8684 commented 12 years ago

Here is the code that worked for me, hope this helps others to follow

     $(document).ready(function() { 
                                  $('img').retina(); 
                                  }); 

                $.ajax({
                       url: "http://www.lcbcchurch.com/mobileJSON/homeslideshow",
                       dataType: "json",
                       success:function(data){
                       results(data);
                       }
                       });

                function results(data) {
                    for(var i = 0; i<data.length;i++){
                        // this will log all of the images url
                        console.log(data[i].slideshow_image); // just access the part you want by it's name.
                        $("#slider").append("<a href='"+data[i].slideshow_image+"'></a>");
                    }
                    picsReady();
                }

                </script>