I\'m getting a \"Object doesn\'t support this property or method error\", does anyone know why?
I do have values plugged into userId, fname, lname, oname, sam, hasAc
toSource()
does not work in Internet Explorer or Safari. It is Gecko-only. See Implementing Mozilla's toSource() method in Internet Explorer for alternatives.
You can either call toString instead, or put in a condition like this...
var jsonstuff = (emp.toSource) ? emp.toSource() : emp.toString();
EDIT:
Since this is not working for you, you might want to use JSON.stringify()
Whilst not recommended (to extend native JS Objects), during development you could use:
Object.prototype.toSource
|| (Object.prototype.toSource = function(){return JSON.stringify(this);})
c = {a:100}
//>Object
c.toSource()
//>"{"a":100}"
cheers!
I suggest using an existing library or plugin:
Try using a JSON serializer instead. toSource
is Mozilla specific and not supported by IE.
If you are just debugging then your best bet is going to be to install Firebug and use console.dir(emp); to print the contents of an object to the console window.
Update: Just notice that on the link you posted it says, "Note: This method does not work in Internet Explorer!" And on the MDC page it says "Non-Standard".