0

I get the following JSON String from server as response enter image description here Here is my Jquery Code

function loadCategories() {
        $.ajax({
            type: "POST",
            url: "/Services/ControllerService.asmx/Get",
            data: {},
            cache: false,
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (result) {
                var jsonArray = JSON.parse(result.d);

                alert(jsonArray);




            }, error: function (msg) {
                alert('Error : while executing the outlets : ' + msg.responseText);
            }
        });
    }

The alert shows the JSON String Correctly. Now i want to map this response to an html table showing columns "a" and "b"

  a        -             b

hasOtherInfo Undergratuate_in_Computing_Faculty

How can i do that ??

1
  • can post the actual response? Commented Jun 15, 2016 at 7:36

3 Answers 3

1
  1. loop through the JSON data.
  2. get the a and b value
  3. write a function that takes care of splitting the value present in results.a.bindings.value & results.b.bindings.value based on the / and #

  4. display the same in your html table 5(optional). use a jquery table plugin to display your results for a feel good look

Sign up to request clarification or add additional context in comments.

2 Comments

Can you give an example
can you use pastebin to paste your json returned data and share the link? pastebin.com/index.php meanwhile you can look at the solution given by user6367045... you need to add the split functionality in there
0

You have some plugin that can achieve that:

Comments

0

As inspecting from your json data you can do this:

var tr="";
$.each(jsonArray.results.bindings, function(i,v)
    {
        var td="";
        $.each(v, function(r,s)
            {
                td+='<td>'+s.type+'</td>';
            });

        tr+= '<tr>'+td+'</tr>';

    });
$("yourTableName").find("tbody").html("").html(tr);

Comments

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.