0

below is my multi dimensional numeric array that i want to process in ajax-jquery using each function of jquery.i am trying to process using parseJSON but in alert result always displayed undefined. So i am not encode this array to process in jquery. Any help would be appericiated. Thanks in advance.

Array
  (
   [0] => Array
    (
        [image_mapid] => 22
        [image_id] => 2
        [user_id] => 1228143758
        [pos_x] => 602.5333251953125
        [pos_y] => 300.3333282470703
        [image_width] => 100
        [image_height] => 100
    )

[1] => Array
    (
        [image_mapid] => 25
        [image_id] => 2
        [user_id] => 1326497290
        [pos_x] => 446.5333251953125
        [pos_y] => 250.3333282470703
        [image_width] => 100
        [image_height] => 100
    )

[2] => Array
    (
        [image_mapid] => 26
        [image_id] => 2
        [user_id] => 1757521573
        [pos_x] => 154
        [pos_y] => 162
        [image_width] => 204
        [image_height] => 190
    )
)

 var tag_select = '<?php echo $basepath?>Userprofile/tagselect.php';

 jQuery.ajax({  
                type: 'GET',
                url: tag_select,
                dataType:'json',
                data: 'wallid='+wid+'&userid='+<?php echo $user_id;?>,

                Success: function(data) {
                   $.each(data, function(idx, obj){
                     console.log(obj.image_mapid, obj.image_id)
                                             })
                                    }

               });

2 Answers 2

2

From what I can see the data is an array of objects so try

$.each(data, function(idx, obj){
    console.log(obj.image_mapid, obj.image_id)
})
Sign up to request clarification or add additional context in comments.

3 Comments

what i get in console.log i assign javascript variable to console.log statement and alert but i get nothing...
hello please reply if you know anything regarding this @Arun
now i edit my question please you check my modification @Arun
1

First remove the dataType:'json' from the AJAX and try it.

And if you provide the Json parsing source, it will be useful to find the actual problem.

Just give the Ajax like below,

 jQuery.ajax({  
                'type': 'GET',
                'url': tag_select,
                'data': 'wallid='+wid+'&userid='+<?php echo $user_id;?>,

                'success': function(data) {
                    // process the array here
                                    }

               });

2 Comments

i tried after remove datyTYPE: 'josn' still no success.. in alert it gave me _firebugingnore... @Akilan
removing dataType : 'json' that i already doing with my code any other update than please help me it's urgent.. @Akilan

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.