queue() call d3.json of world-110m.json produces syntax error for a worldmap with topoJSON - json

I successfully completed the "Let's make a map" tutorial and now want to make a world map. However, all examples I tried (a couple from mbostock) only display background graphics in chrome and firefox. I get the following error in firebug:
SyntaxError: JSON.parse: unexpected character
return JSON.parse(request.responseText);
in d3.v3.js but I assume it starts with the following code in the index.htm:
queue()
.defer(d3.json, "world-110m.json")
.defer(d3.tsv, "world-country-names.tsv")
.await(ready);
The call d3.json of "world-110m.json" seems to produce the error. I have found nothing about this error on the internet -- I'd appreciate some help.

Related

Laravel + Vue Error in render: "SyntaxError: Unexpected token u in JSON at position 0"

I have a Laravel application with Vue js and until a while ago it was working perfectly. Now when I go to any page that uses Vue js this error appears: [Vue warn]: Error in render: "SyntaxError: Unexpected token u in JSON at position 0".
When I reload the page by clearing the cache (Control + Shift + R on Mac OS) it works again, but when I update without this command the error appears again.
PS: I didn't do any package updates for both laravel and npm, it just stopped working out of nowhere.
Try this in the console:
JSON.parse(undefined)
Here is what you will get:
Uncaught SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse (<anonymous>)
at <anonymous>:1:6
In other words, your app is attempting to parse undefined, which is not valid JSON.
There are two common causes for this. The first is that you may be referencing a non-existent property (or even a non-existent variable if not in strict mode).
window.foobar = '{"some":"data"}';
JSON.parse(window.foobarn) // oops, misspelled!
The second common cause is failure to receive the JSON in the first place, which could be caused by client side scripts that ignore errors and send a request when they shouldn't.
Make sure both your server-side and client-side scripts are running in strict mode and lint them using ESLint. This will give you pretty good confidence that there are no typos.
Sometime it is becaseu of this let data = JSON.parse(this.response); so try to change it to
let data = JSON.parse(this.responseText);
I really did was change this.response to this.responseText

Wakanda server start JSON error unexpected EOF

WAK 1.1.3 - during solution load, get a backend error:
[Backend] Error
[Backend] SyntaxError: JSON Parse error: Unexpected EOF
But it is not clear what file has this issue. How to most efficiently isolate this? I see nothing in the logs. The application has been running stably. I assume this is in a method, but am not finding it after a thorough search.
Thanks for guidance.
Kirk
Unexpected EOF error could be as small as forgetting to close function body with a right curly bracket.
I recommend first checking all the code on the backend you have modified since the last successful restart.
Secondly, since this occurs during solution load, the error is likely in bootstrap code including login listener. Or in model.js. You could try comment out all code in bootstrap.js or model.js see if the solution can load.

Appcelerator message = "JSON Parse error: Unexpected identifier \"undefined\"";

I am adding new features to an app I wrote last years and is working now ... I just port the code from Appcelerator (3.2...) to the Appcelerator Studio 5.2.0.GA SDK ... and I have spent 2 days trying to figure out why code that currently works on an app in the app store is not working in the SDK 5.2.0 environment
I keep getting the above error .. I am positive the url is correct and working
This line of code works now in the app in the store and in 3.1... but is not working in 5.2.0
var jsonObject = JSON.parse(this.responseText);
It gives the above error
"JSON Parse error: Unexpected identifier \"undefined\"";
I have read their site and searched for a solution ... Thanks
entire Block
Try one thing:
Open this site and put your response data in which you are getting error https://jsonformatter.curiousconcept.com
After parsing the same data on the above site, you can check whether the problem is really in your Titanium code or in your data.
Also check whether you are really getting any response data or not.
If it does not help, then please share some necessary source code
Thanks

How to retrieve error message from xOptions in jquery-jsonp library

I am using the 2.3.1.min version of the jquery-jsonp library found here: https://github.com/jaubourg/jquery-jsonp and it works as expected, namely the error function fires when an error occurs. However, I cannot to seem to display the error encountered. I checked the docs on github project but could not find an answer.
Is this a limitation? Or am I not calling the right object?
My implementation..
The url parameter below is set to return a 404 page on purpose. Chrome dev tools shows a 404 response, but I cannot seem to capture that result..
<script type="text/javascript">
$.jsonp({
url: 'http://apps.mydomain.com/Service/NonExistant?&max=4&format=json',
callbackParameter: "callback",
error: function(xOptions, textStatus){
// this lines returns "error"
console.log(textStatus);
// this returns the Object (but expanding it reveals no indication of error code / message)
console.log(xOptions);
},
success: function(json, textStatus) {
Populate(json); // this works fine
}
});
</script>
Sadly, you can't. Johnny Wey explains it far better than I could - but essentially, it's relying on a "script" tag to get the JSON response, rather than a request executed via javascript.
You could wrap the type of error within the JSONP response per Parsing JSONP Response in Javascript when 4xx or 5xx Http Error Code is Present, but that still won't help you with a 404 error.
Unfortunately, though JSONP error handling is effectively non-existent. The "Cautionary Note" from IBM specifically mentions that "First and foremost, there is no error handling for JSONP calls".

Safari and Chrome do not want to JSON.parse

I'm trying out localStorage and JSON using a variety of browsers with this piece of code:
function getStorage() {
stored = JSON.parse(localStorage['test']);
if (typeof stored == 'object') {return stored;}
}
Chrome gives me the following error message: "Uncaught SyntaxError: Unexpected token u" for the first line inside the function body. For that same line, Safari says "SyntaxError: Unable to parse JSON string". Firefox does not give any error messages for that line.
Other JSON.parse examples (from books, etc) work fine in both Safari and Chrome. For instance, this one from "Pro JavaScript" by Nicholas Zakas:
var jsonText = "{\"name\":\"Nicholas C. Zakas\", \"age\":29, \"author\":true }";
var object = JSON.parse(jsonText);
alert(object.name); //"Nicholas C. Zakas"
No problem at all with getting that to work. Local storage also works fine in both.
I've also checked the encoding on all my files using file -I my file and all files, both my own and the ones from the above book, are encoded as filename.html: text/html; charset=us-ascii - so encoding doesn't seem to be the problem here.
This is perplexing. Thanks a lot for any help.
/ James
It's because the content of localStorage['test'] is undefined, hence the unexpected u.
Thanks for the advice on debugging the contents of localStorage directly. The bug was in the line if (localStorage.length == 0). I had some other data in localStorage from previous apps, so json didn't get set to anything inside that conditional.