Select to view content in your preferred language

parser.parse() error in .js file

2484
2
11-07-2013 12:04 PM
MatthewBrown1
Deactivated User
Hi,

I'm getting the following error when calling parser.parse(); in map.js


[INDENT]0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'parse'[/INDENT]


However, if I run the code from map.js in the HTML file, it works perfectly. Do I have to call parser.parse(); differently when using .js files?

Thanks,

Matt
0 Kudos
2 Replies
JasonZou
Frequent Contributor
If you are using AMD style, check if the module aliases match the dependency list. Take below code as an example. module1 is the alias of path/to/mod1, module2 for path/to/mod2, and so on. You can skip some dependencies not assigning them aliases, like path/to/mod4 in below, but all the skipped modules must be at the end of the dependency list.

define(["path/to/mod1", "path/to/mod2", "path/to/mod3", "path/to/mod4"], function(module1, module2, module3) {
    // body content
});

More than likely, in your map.js, the position of parser in the alias list does not match the position of module dojo/parser in the dependency list.

Otherwise, please post map.js code for further inspection.
0 Kudos
MatthewBrown1
Deactivated User
Hi Jason,

I checked the AMD require format, and it was fine (I did a copy and paste into the HTML and it worked). I've also been using Derek's AMD require generator to check. I figured I'd made a noob mistake like that but it seems like the problem is something in my IDE - VS 2012. Not sure what happened, but after closing down the solution for a while (I opened it up to respond to your post), the original code worked.

When I first hit the error I cleared the browser cache for Chrome and IE, killed IIS Express, and rebuilt the solution with no change.

We are supposed to use VS and TFS, but perhaps I should perform my prototyping in Aptana? Any folks out there using VS for the JS API?

Thanks,

Matt
0 Kudos