AnsweredAssumed Answered

Clicking on Graphic throws "has no method 'toJson'"

Question asked by nobleach on Jan 10, 2014
Latest reply on Jan 10, 2014 by nobleach
I have created a method that adds a graphic to a map based on the result from an ajax call:


_uploadComplete: function(result) {           /* This event is raised when the server send back a response */           var res = JSON.parse(result.currentTarget.responseText);           var xypt = JSON.parse(res.params.point);           var pt = new Point(xypt.x, xypt.y, xypt.spatialReference);           var symbol = new esri.symbol.PictureMarkerSymbol({             "angle": 0,             "xoffset": 0,             "yoffset": 0,             "type": "esriPMS",             "imageData": "iVBORw0KGgoAAAANSUhEUgAAABgAAAAVCAYAAABc6S4mAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJ bWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdp bj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6 eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0 NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJo dHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlw dGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAv IiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RS ZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpD cmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFu Y2VJRD0ieG1wLmlpZDowRURFN0Q3OTcyMjcxMUUzQjJCM0NBMjZFRDAyQ0EwNiIgeG1wTU06RG9j dW1lbnRJRD0ieG1wLmRpZDowRURFN0Q3QTcyMjcxMUUzQjJCM0NBMjZFRDAyQ0EwNiI+IDx4bXBN TTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOjBFREU3RDc3NzIyNzExRTNC MkIzQ0EyNkVEMDJDQTA2IiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjBFREU3RDc4NzIyNzEx RTNCMkIzQ0EyNkVEMDJDQTA2Ii8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4 bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+ye/0wQAAAZhJREFUeNqslTtIA0EQhu+SoAiaKCgS YuOhVtr4BisRrKwExUa09gHaK0bBZydiI1poo4XYaGVvbSXYpPANaYMRX4n/wH9wLHfJ7XkDH3vL 7s6/Ozs7ZyZTC4YPGwNbYAMcGRoW8TlvGVjgEOTBTJgCg6ADjIMB8AT2QREsglipxaaPEInDpOJo GGyCTvZXwTb40D1BF2gC6i6uOSanuwErDJ3cU63OCT5Bhcwrs5FuOh9iX0K4BrLRmnh/qYV5XvBr GQEZPwEXIAUmwTxokBNc4aMNNCqLCuAOVIEWF6cv4Iw7Va0evMm9iYBkwze49REK22RNL8h4iNtz pu3MSPMR6dgeGPUYO2V7bGdRwtC3ap7cLTMn7MyzBcwAAibDoNqus40Y4dscWNetRV5WqfTTbJfC EngG7WCEfXnRB26lohDAeZFvoRlcMmV/waybQC6AwDszKcu+xQL445wUYwWcYmXUeWg94BzEHVHY USeKwBdoJboWBffggRU25yaQ+Mcl9/F/YXkljAg8grqAAhlHeFwT5U+AAQBxC0/GeQAo7QAAAABJ RU5ErkJggg==",             "contentType": "image/png",             "width": 24,             "height": 24           });           var attrs = {             username: res.params.username,             timestamp: res.params.timestamp,             link: res.name,             accuracy: res.params.accuracy           };           var infoTemplate = new InfoTemplate("Test", "Test");           var graphic = new Graphic(pt, symbol, attrs, infoTemplate);           console.log(graphic);           map.graphics.add(graphic);           document.getElementById('progress-meter').style.width = '0%';           map.enableDoubleClickZoom();         }


The graphic gets added just fine, but when I click on it, the console logs:

Uncaught TypeError: Object #<Object> has no method 'toJson'


The rest of the features on my map (from loaded featurelayers) work just fine.

Outcomes