Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

printing values of object in jquery

Tags:

I have below code that get values from a grid. Instead of printing the values, the grid is printing data in below object format. How to print values?

[object Object], [object Object], [object Object], [object Object], [object Object] 

CODE:

$(document).ready(function () {     $("#check").click(function(){         var rows = $('#jqxgrid').jqxGrid('getrows');         alert(rows);     }); });         
like image 737
user1710288 Avatar asked Oct 13 '12 22:10

user1710288


1 Answers

A simple way is to use

JSON.stringify(rows) 

i.e.

alert(JSON.stringify(rows)) 

Else, you would need to manually traverse the object's properties and print them accordingly. Give more details about input and desired output for an example.

An example in interactive Node.js:

> x = { 1: 2, 3:4 }; { '1': 2, '3': 4 }  > x.toString(); '[object Object]'  > JSON.stringify(x) '{"1":2,"3":4}' 
like image 187
Rudolf Mühlbauer Avatar answered Oct 15 '22 12:10

Rudolf Mühlbauer