getJSON issue not seeing retrieved data

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

getJSON issue not seeing retrieved data

jjanes

I am familiar with programming using PHP and javascript but have not used jQuery much at all.
I am using sample code that does work but when I try to implement a similar function I can't get any output at all.

Here is a sample of the working function I am trying to build upon
Copy code
        <div id="page1">
            <script type="text/javascript"> $.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?", { tags: "any", tagmode: "any", format: "json" }, function(data) { $.each(data.items, function(i,item){ $("<img/>").attr("src", item.media.m).appendTo("#page1"); if ( i == 5 ) return false; }); }); </script>           
            Go back
        </div>

This goes to an external server and retrieves and process the data then displays it.



This is my segment of code which I can not get to work properly. All I see is the Go Back button
Copy code
        <script type="text/javascript"> $(document).ready(function() { $.getJSON("http://www/imobilizeit.com/jeff/jeff.php?jsoncallback=?", function(data) { $('#datasrc').text(data); }); </script>   
This is the part of my code block where the data should be displayed


Copy code
       <div id="page2">
            <p id ="datasrc">hello</p>
            Go back
        </div>

When I browse the link I am using the getJSON on in a regular browser this is what I see

Copy code
{"Bday":19630918,"extimg":"first"}

Now in PHP I can use the print_r command to view data in an array where as if try just echo all that is output is Array but I do not know the equivalent in query if it is indeed needed

From what I have read I believe the syntax of my script is correct
This should as I understand it

$('#datasrc').text(data);

sets the content of the element with the ID of datasrc to be the data I get from the call
and that ID is in the DIV with the ID of page2
When the page is starts to load that element is hello and then when the page finishes loading the ready function is called and the information there should be replaced with data

The code is being run from an iOS device and as stated earlier the original function succeeds calling an external server.

My function calls another external server.

I think the problem is the format of the data I am receiving and it may be that I am not processing it correctly.

I hope someone can please point my in the right direction

Thanks

Jeff