You don't need to eval the JSON data. Let jQuery do it for you. Simply
change $.get to $.getJSON. Or, if you prefer, use $.ajax with
dataType:'json' for more flexibility (such as the ability to have an error
callback).
 
Regarding the array vs. object coming from the server, that would be a
question of how you write your PHP code. It wouldn't be affected by jQuery
one way or the other.
 
-Mike



  _____  

From: Dhruva Sagar

I think this is what you are looking for 


data = eval ( '(' + data + ')' );


Thanks & Regards,
Dhruva Sagar.


Jonathan Swift
<http://www.brainyquote.com/quotes/authors/j/jonathan_swift.html>   - "May
you live every day of your life." 


On Wed, Aug 12, 2009 at 3:18 PM, Mark <johanns.m...@gmail.com> wrote:



Hi all.
I got an php page who picks up data out of my data base and puts it in
a multidimensinal array. That array is being encoded to Json

$event = json_encode($super_array);

Then i made an javasript get funtion to get that array to my main
page.

function get(){
                $.get("../position of my file/test.php", function(data){
                       alert (""+data);
                       });

The var data doesn't give me an array it gives me an object while i
programmed it to give me an array (inplace of force_object):

{"5":
{"id":"5","title":"test","start_datum":"6161616","end_datum":"663461","afspr
aak_type":"memo"},"10":
{"id":"10","title":"bla","start_datum":"4819028","end_datum":"8230948","afsp
raak_type":"verjaardag"}}

What i need to have is that it gives me an array that looks something
like this:

[
 {
    id:5,
    title:test,
    start_datum:6161616,
    end_datum: 663461,
    afspraak_type: Memo
 }
 {
    id:10,
    title:bla,
   start_datum: 4819028,
   end_datum:8230948,
   afspraak_type:Verjaardag
 }
]
What is the best way to get to this?

Mark




Reply via email to