SyntaxError: missing ; before statement when adding new script - javascript

I get the following error in Firebug for my JavaScript application:
SyntaxError: missing ; before statement when adding new script
The error relates to Google Analytics, but I only get the error when I add another script using RegisterStartupScript. I've had same error point to the script below whilst testing too, so I think the Google thing is a red herring.
Here is the script that gets rendered:
<script src="https://www.thedomain.com/pixel/confirmationjs?pthru=1055|1|pixeltest|27902471&dlp=1.20">
</script>
How do I solve this problem in ASP.NET with RegisterStartupScript?

When getting your technical info of a salesman, never accept what he says to be the complete story or the whole truth!
Turns out that the pixel image I was testing against was single use only, so it worked first time and gave an error on subsequent calls.

Related

HOW TO RESOLVE: Uncaught (in promise) SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

Uncaught (in promise) SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
This error occurs in Firefox console when loading 3rd party Javascript. But Firefox console gives absolutely no information as to whereabouts in the JS this issue occurs. The 3rd Party JS has a host of different JSON parts to it.
I am not familiar enough with JS to dig in and mess around with the code toooo much or spend hours fragmenting it and taking it apart and putting it back together again.
NOTE
There are a lot of questions with identical titles, and each of these show very specific issues with very specific responses. My question is not really about wanting to find the issue in this case (although that would be great).
My Question
How should I (any anyone else) approach trying to find where this error is;
How do we find what data is causing this error?
How do we find which line of JS causes this error?
Reading the MDN (etc) on JSON errors It seems to be easy to resolve once it's been found, but the case is I am having troubles finding how to go abouts digging out where in the JS this issue occurs and/or which data is causing the JSON error.
UPDATE
Further to comments, here is the Debug flow output from Firefox; I'm a little lost in here but this still doesn't seemt to show me what is actually going on.
Some clear pointers that came up in the comments below the question:
Use the Debugger Firefox Inspector tab before refreshing the page and reloading the error.
Somewhat unexpectedly, when on the Debugger tab, the same console error (at the bottom of my screenshot) this time shows a file reference and line number reference and can be clicked on to show a cascade of details.
As mentioned by evolutionxbox and Barmar the Debugger tab should also be showing the variable that's used in the call to JSON.parse.
Using the Debugger Breakpoints tickboxes was very useful for establishing what part of what code was running when the error was encountered.
More will be added here

Debugging Ember JS -- Identifying line in code that causes an error

So I'm getting the following error:
Uncaught Error: Assertion Failed: The key provided to get must be a string, you passed undefined
Should be easy enough to fix, if there was any indication of the line in my code that causes that error.
Using the chrome console, I click on ember.debug.js:6254 next to the error, which just shows me the ember code that throws the error. I can expand the error, but I just get a bunch of functions that can't be clicked on and no indication where they come from.
Can someone please help me figure out how to identify the line in my Ember code that is causing the error.
I've gotten this error before. It happens when you call get() in any of its forms (Ember.get() or this.get() or get(this)) without a string as the name of the property you want to retrieve.
You should be able to find the source of the error by auditing your application for wherever you call get() and making sure you pass the property name as a string. E.g., Ember.get('model.someProp') or this.get('someProp') or get(this, 'someProp').
This should be a comment but I can't, so here goes:
Iam new to Ember and have been spending quite a long time debugging. Remember that long stack of function calls that chrome's console shows.
Look for anything other than ember.debug.js...especially those marked (anonymous function) and files with names vendor.js or app-name.js
Usually in software development when debugging your best friends are going to be console.log() or alert() (in the case of JavaScript). Usually you have to figure out if your getting what ever is that you passing to your function by consolelog everything until you find your bug. Ember sometimes will not tell you what is exactly the error because does not know where exactly is coming from.
...computers are annoying but we love them....
here are some articles from Mozilla developer and Google on how to debug JavaScript.
I had a NULL value in my database which I wasn't accounting for in my app. In my case, it shouldn't have been NULL in the first place, so after giving the record a value in my database the problem disappeared.
I agree the error message is not very helpful.

(index):889 Uncaught SyntaxError: Unexpected token <

I'm using Google Analyticator and my website is http://gestionalemagazzinoonline.it/
You can see the error in the javascript console.
I think that is the suspected file:
https://github.com/wp-plugins/google-analyticator/blob/master/google-analyticator.php
The problem is also if i disable the plugin, or if i change the source code i don't see the changes (maybe there's a cache?).
How can I fix?
Script tags are meant to write javascript in them, and not html.
You have a script block inside a script block. Remove that, and it will work all fine.

angularjs error in console log for jsfiddle

I am working on an Angular grid project and i am facing a minor error while using angular-grid.
Heres the error- Module 'angularGrid' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
So i thought i am missing out on something. I checked a JSfiddle and was not able to view the output there. So i checked the console for errors. here also the same error is displayed.
JSfiddle is not even edited by me. I am just viewing the link. Yet i get the same error.
http://jsfiddle.net/9b5gnjf1/8/
<md-toolbar class="md-whiteframe-z2">
<div class="md-toolbar-tools">Toolbar</div>
Just adding the above 2 lines from the link so that stackoverflow lets me paste the jsfiddle link. without any code written, it doesnot allow to post the link here.
anyone knows what kind of error is this and how to solve it ?
There's a 404 error resolving the external link to the javascript file that the angular-grid module lives in.
Looks like either it's a bad link, or the rawgit servers are down.
You can either wait and hope the link comes back to life, or replace the broken external resource with a working one.

javascript I can not catch the syntax error

I'm working on a project which needs to use youtube api. The html and javascript works fine in different browsers. Yet When I just WPF's webbrowser to run it, I get the following error:
Script Error
line:1
char:1
Error: Syntax Error
Code:0
URL about://:/
Do you want to continue running scripts on this page?
yes no
When I click yes, the message box went away and the program just works fine. I comment out most of the content on the html file and found that the following sentence caused this problem:
google.load("swfobject", "2.1");
So now, I just want to catch this error, just don't want the messagebox to popup. I tried
try{
google.load("swfobject", "2.1");
}catch(err)
{alert("caught");}
Yet, I still get the initial error box. Is there anyway to remove the error box? Thank you very much.
You can't actually use try/catch blocks to catch syntax errors. A syntax error means that the parser can't correctly parse the JavaScript. Syntax errors happen before the code is ran.

Categories