I am getting this error after an AJAX call fails and I'm trying to log the error object by stringifying it and saving it to the sesssionStorage. The site is not in compatibility view or enterprise mode, it is IE11 and the doctype is <!DOCTYPE html>, the document mode is Edge and the user agent string is Default. This is only happening once in a blue moon so it's hard to track down what is happening. I haven't been able to get the error that is being thrown yet, however I will just create my own string that catches the details of the error that I need for now and then hopefully be able to move forward.
Has anyone else run into a situation where JSON should be available but isn't? Again, all the doctypes/compatibility settings are fine and this only happens once in a blue moon.
Read about stringify here.
The cause of your problem is that you try to call the stringify method of a variable which is a null reference or is undefined. To make sure this is not the case, validate your value to be a valid JSON:
function isNullOrUndefined(param) {
return (!param);
}
then before you call stringify for foo:
if (!isNullOrUndefined(foo)) {
//some code involving foo.stringify
}
Apologies Steve,
I'd been having a noobs stringify issue and couldn't find a solution anywhere while getting the same error message. I'm happy to admit here, in the hope it can help others, make sure you've updated to a recent version of jquery, I'd been using version 1.4.1 shipped with VS2010, now using 2.1.3 with the help of NuGet packages.
Hope it doesn't go against the rules or offend you, but this really does feel like the best place to offer out this info even though I'm sure it is of little support to you.
Related
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.
I have run into an issue that I believe is rooted in the implementation of anchor tags in Rhino. Although I am utilizing env.js, I suspect perhaps I am not configuring something correctly.
In particular, my issue occurs while I am attempting to write unit tests against code written for an angularjs application. When I include angular.js (versions 1.2.1 to present), I get the following error:
TypeError: Cannot call method "charAt" of undefined
I am convinced the error is the result of this call to urlParsingNode.pathname since a console.log call reveals that the pathname object is undefined.
I traced the instantiation of the urlParsingNode to this line where we see that it is the result of a call to document.createElement("a"); Further down, we see that they set the href attribute in this line in hopes that the created anchor tag will utilize the browser to correctly parse the URL.
I have to believe I'm not the first to attempt JS unit testing for angular via Rhino, but thus far I've not successfully Googled myself to a solution. Any tips will be greatly appreciated.
Found it and fixed it. The pathname getter/setter simply was undefined for HTMLAnchorElement in env.js.
I submitted a pull request, but unfortunately the project looks all but abandoned. I also couldn't figure out how to build it out to a single file. It appears perhaps someone has taken it upon themselves to break it apart into require.js modules. Not a battle worth fighting for my use case.
So for anyone else who hits this issue, I have the code you need below. It belongs in the HTMLAnchorElement.prototype. In my copy of env.js 1.2, this prototype begins on line 8075. I added the following at line 8118.
get pathname() {
var uri = Envjs.urlsplit(this.href);
return uri.path;
},
set pathname(val) {
var uri = Envjs.urlsplit(this.href);
uri.path = val
this.href(uri.urlunsplit(uri));
},
FYI, my particular issue is resolved with this pull request.
TypeError: Unable to get value of the property 'childNodes': object is null or undefinedundefined
After making a long list of modifications to my application in order to support IE8, including:
running all of the views in their compiled form through W3C validator, setting up xdomain.js proxy to support CORS API calls, making some general restructures, etc.
I was very disappointed to find out that IE8 still throws this weird error at me, while IE9 works perfectly fine.
Making changes to the Angular-seo package to prevent it from running when the client is an IE browser.
Any ideas on what can it be?.
Make sure that all your tags are closed properly. I just spent hours trying to figure out what the problem was, until I noticed this in my code:
<span>some text<span>
I finally realized I didn't close the <span> tag properly. After that everything just worked.
Without the code you are running it is a bit difficult. However there is a command to use for debugging. First you need to identify which variable might not contain an object [i.e.
"object is null or undefined"].
For example, parent, then you can use
//next look to see if parent is something
if('undefined'==(typeof parent)) alert("variable empty:parent");
Once you find something that is empty that you are expecting to be an object then you can go trace back from there. Also use a browser debugged tool, to identify the line number of the error.
Often if using the child nodes, you may not have the right level or you need to access as an array i.e. you need something like.
parent.childNodes[0].childNodes[0].value
In IE you are also dealing with unsupported functions. So getElementById will work but some other similar ones do not. Again typeof can be useful.
//next ensure function supported
if( 'undefined'==(typeof document.getElementsByClassName) ){
alert("Not Supported"); // notice ^ no () required here
//...add code to handle differently when not supported
}
This may reveal if you can use a function
IE8 is so old and non-standards compliant it doesn't support childNodes[]. http://quirksmode.org/dom/core/#t70
I am having problems finding the solution to two errors on a web site I am building on a Joomla 3.0.2 platform and using the Gantry Framework.
The first error is:
Type issue
'null' is not an object (evaluating 'b.appendChild')
The second error is:
Type issue
'undefined' is not an object (evaluating 'rikgallery_slideshow.jump')
I have never understood how to debug javascript errors, so I would really appreciate some help.
The site can be accessed at: http://lads.ergonomiq.net
If someone can help and needs super user access to the back end, please email me at ali.samii#ergonomiq.net
Thanks
This is meant to simply point you in the right direction, further testing will be required to fully solve your issues.
OK the first error is happening in responsive.js line 66
menu.inject(document.getElement('.menu-block'));
I would console.log(menu, document.getElement('.menu-block')) make sure both contain an element as expected. I am guessing one of those will be null.
Second error
AjaxURL: 'http://lads.ergonomiq.net//index.php?option=com_roksprocket&task=ajax&format=raw&ItemId=101'
is returning unexpected JSON
{"status":"error","message":"Unable to find class for item ","payload":null}
I would test the error and only proceed if you have images in your returned JSON
Line 136 of your home page.
Hope this helps
I have never understood how to debug javascript errors, so I would
really appreciate some help.
If you want to debug JavaScript errors, you should be using FireBug with the FireFox browser. You can get the FireBug Add-on here. You will then be able to find these bugs yourself.
I don't know if this has been asked before, but what i'd like to be able to do is get data from the error console within the browser itself(if it supports it) this would be for when a user sends off a bug report it'd pull up any errors related to pages at my website for things such as typos in code and other things that somehow managed to slip by. Also, in that regard is there a way to pass the errors from the console to a useable format? If this isn't possible, then i could just tell them to copy and paste what came up from the site itself.
I thought of this right now as i was thinking about how to make the bug reporting system run better since the entire thing is basically ran within the browser and for the backend I can easily just look at error logs but for the frontend ie javascript bits of things it's not goign to be as easy.
So to finish wrap all of this up in one little statement, is there an easy way to get the data from the error console and be able to send it along via javascript ie to a form, or something similar.
You can use the onerror event in JS to get the details of the error. Hoptoad do this for example and log the errors to their console, Their code re-uses lots of nice JS scripts including a printStackTrace function that is great.....
You can see how they do it here:
http://hoptoadapp.com/javascripts/notifier.js