Select to view content in your preferred language

print button is unresponsive due to "syntax error"

748
3
08-01-2013 07:16 AM
RyanWhiley
Emerging Contributor
Hey everyone. 
I'm trying to implement a print function into my application.  But it's not working.  My application has a console.log that spits out the error.  Apparently its an error in the [url=http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/]jsapi/arcgis/3.5[/url] on line 15 which begins with the text "//>>built" and appears to have a lot of errors in it. Has anyone else encountered this problem before?

Thanks a lot!
Kyle
0 Kudos
3 Replies
SteveCole
Honored Contributor
When console errors appear that point to the API itself, the actual issue lies elsewhere. In your browser debugger, examine the Call Stack when the error occurs and follow the stack from the API location back up to the point of your code. From there, look at your line of code and verify that you're passing the correct parameters to an API method (string versus numeric, etc). This is the kind of thing that festers and doesn't appear until some part of the API is expecting a number but gets a string. This is what makes the API look like it has an error.

Good luck!
Steve
0 Kudos
RyanWhiley
Emerging Contributor
Hey evtguy, thanks for the reply.

But I'm pretty new to js, so how would I go about tracing back to the problem?  I have firebug.  Would I have to enter some more code that will show up in the console that I can trace?

Thanks,
Kyle
0 Kudos
SteveCole
Honored Contributor
Kyle,

In Firebug, the call stack is located in the right window pane (it's a tab named "Stack") when you are viewing your javascript. The call stack will only be visible when your code stops (via error or breakpoint/pause). If the print error stops the javascript in its tracks, the stack should be viewable at that time. I've attached a screenshot example of it. In my example, I clicked on a feature in my map and the code running it querying the featureLayer for features so it can populate the information in an infoWindow.


The top of this list is the "top" of the stack and shows you what code is currently running. The bottom of this list is where your code initially was kicked off. So, in this example, I clicked on a feature in my map (bottom entry) which, in turn, triggered an onClick event for my featureLayer (second to bottom entry). This, then triggered a query on the features in my featureLayer and those are the two entries at the top.

If you don't see it, the best way to tackle the issue is to add a series of lines in your javascript which print text to the console like this:

console.log('Passing Checkpoint 01..');


Add these with incremental numbers (01,02,03,etc) throughout your code and pay attention when you run your app. This can help you focus on where in your code that things go south. Through some trial and error, refine the placement of these console messages until you can figure out the line of code that triggers the error.

Once you know that, place a breakpoint on the line of code which throws the error. You do this by clicking on the line number (a red circle will appear next to the line number). When you re-run your code, it will stop at the breakpoint and you can examine the call stack as well as the various objects that get created/population by your code. Make sure that objects that should be populated actually are, and with the correct type of object.

This may not be possible but, if you have a link to a public facing project (or can post your relevant code), folks here on the forum can look at it and help troubleshoot it with you.
0 Kudos