I am using a jQuery plugin which returns the object, for example using the below code.
onSuccess: function(data, status){
alert(data);
}
returns [object Object]
as it is returning the object i would like to know how do i check all the contents that holds inside that object using js alert();
also i would like to know if JS object and JSON are one and the same.
thank you
Use proper debugging tools like Firebug for Firefox or the built in Chrome developer tools. Then you can inspect objects with
console.logorconsole.dir.alertis not meant for debugging. It can only output strings, which is of limited use as you already noticed.No, they are not. JSON is a data exchange format, similar to what XML can be used for, whereas a JavaScript object is a data type in JavaScript.
If you are wondering whether JavaScript object literals are JSON, then this answer has to be answered with no as well.
These are object literals
whereas JSON can only exist inside strings in JavaScript:
and which then has to be parsed into a equivalent JavaScript data type. This is done by parsers such as the built-in
JSONor json2.js.Don’t let their similar syntax/structure fool you.