Hello,
I have written an ajax call:

$.ajax({
                url:'summary_page_data',
                type:'POST',
                data:name={},
                context: this,
                dataType: 'json',
                success:function(data_){
                                        if(data_!= -1)
                                        {
                                            data=JSON.stringify(data_);
                                            alert(data);
                                            $('#write_table').append('<p>Summary:<br><br>[FORM TABLE HERE]</p>');
                                        }
                                        else
                                            alert("outside")
                                    }
                        });

In this "summary_page_data" i have written echo json_encode($skills);
SO it is returning array.
when i alert the return data,
it shows me [{"field_name":"Operating System","field_value":"Linux"},{"field_name":"Operating System","field_value":"Protocols"}]

Now i want to make an array of this return .
and print that array in table

But how to form an array of json return?

What you show in the question would appear to be the returned JSON, decoded then re-encoded (re-stringified).

It woud be more useful to see the raw JSON, which may or may not be the same as the re-encoded JSON. To do this, temporarily use dataType:'text', and alert (data_).

Hi,
Thanks for your inputs
i did

$.getJSON('summary_page_data', function(data) {
         $('#write_table').append('<p>');
        $('#write_table').append('<label for="Summary" style="width:170px!important;">Summary</label><br>');
        $.each(data, function(index) {
                        $('#write_table').append('<tr><td>'+data[index].field_name+':'+data[index].field_value+'</td></tr><br>');
        });
        $('#write_table').append('</p>');
    });

like

Be careful ...

  1. jq.append() doesn't work the way you think. .append('<p>') will append an entire p node and is equivalent to .append('<p></p>') or (more economically) .append('<p/>'). Although it is syntactically incorrect, .append('</p>') will append another etire p node.
  2. With regard to node hierarchy, populating a DOM from jQuery obeys the same rules as populating from HTML. A table element will only accept thead, tbody and tr nodes. Browsers are error-tolerant but the rendering of any other node type appended to a table is indeterminate - typically above the table.

I expect you want something like this :

$.getJSON('summary_page_data').done(function(data) {
    var $tbody = $('<tbody/>').appendTo('#write_table');
    $tbody.append('<tr><td><label for="Summary" style="width:170px!important;">Summary</label></td></tr>');
    $.each(data, function(index, item) {
        $tbody.append('<tr><td>' + item.field_name + ':' + item.field_value + '</td></tr>');
    });
});
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.