0

I have a jQuery app that dumps a film catalog in various ways. I develop with Internet Explorer, checking against Chrome and Firefox if the app is to be available to others.

Yesterday, I rebuilt my workstation to use Windows 10 (from 7), which replaces Explorer with Edge. The code that I had finished the day before (and posted on the web) no longer runs under Edge (or Chrome). In both cases, the $.getJSON call fails. JSONLink Pro confirms that the JSON file is, as the day before, just fine.

"Error requesting page dbMovies_short.json"

I replaced my own code with this from the jQuery API documentation:

var jqxhr = $.getJSON( "dbMovies_short.json", function() {
  console.log( "success" );
})
  .done(function() {
    console.log( "second success" );
  })
  .fail(function() {
    console.log( "error" );
  })
  .always(function() {
    console.log( "complete" );
  });
jqxhr.complete(function() {
  console.log( "second complete" );
});

No difference. Console log shows: "error, complete, second complete". "..._short.json" is a four-item version of the full data file.

I have been using jQuery 1.11.3. When that failed today, I switched to 1.12.0. No change.

Any suggestions?

Michael Broschat
  • 875
  • 3
  • 10
  • 17
  • Please, change this `fail(function() ` to this`fail(function(jqXHR, textStatus, errorThrown)` and check their content doing this: `console.log(jqXHR, textStatus, errorThrown)` – Eduan Lenine Jan 18 '16 at 00:11
  • Thank you, Eduan. My own code uses the version of fail() that you note, but it makes no difference. – Michael Broschat Jan 18 '16 at 00:42
  • But what is the content of those parameters in your code? – Eduan Lenine Jan 18 '16 at 00:45
  • textStatus returns "error" and errorThrown returns empty. – Michael Broschat Jan 18 '16 at 04:38
  • I've tried this now in both Chrome and Firefox. Chrome behaves as does Edge but the code runs fine in Firefox. My guess is that permissions are somehow at the root of this. – Michael Broschat Jan 18 '16 at 15:00
  • I don't know why this is happening in both Edge and in Chrome, but it doesn't happen in Mozilla. More to the point, I've discovered that IE 11 comes with Windows 10, even if it's not easy to see. I have no complaints about Edge (the new browser), except that it doesn't appear to work with jQuery AJAX (on the local machine). Are Edge and Chrome related, I wonder? All browsers work fine with jQuery AJAX when the content is based on a server. Because of this, I tried setting the Ajax property to isLocal, but that made no difference. – Michael Broschat Jan 20 '16 at 14:53
  • In console log, when you make the request, what's happening? A stupid question, where the file dbmovies_short.js is located? – Eduan Lenine Jan 20 '16 at 19:55
  • As noted above: "error" and empty. One test using another parameter also yielded "404," which I presume just means that it couldn't access the file. Which is in the same folder as the code. – Michael Broschat Jan 21 '16 at 21:26
  • Instead of use the relative path try to use the absolute path to the file dbmovies_short.js, like http://localhost/path/to/dbmovies_short.js 404 means that the file doesn't exist or you are referring to this with that wrong path. ;-) – Eduan Lenine Jan 22 '16 at 01:40
  • Can you access the file directly from url via browser? – Eduan Lenine Jan 22 '16 at 01:46
  • how do you access your script or application? At first there's no problem with your script. The problem, I guess, is the location or access url used to json file. – Eduan Lenine Jan 22 '16 at 13:58
  • Yes, I can directly access the JSON file: H:\DiscCatalog\dbMovies.json. I develop in TextPad, which has a command to render the current file in the default browser. – Michael Broschat Jan 23 '16 at 03:03
  • change the path to it: `$.getJSON("/dbMovies.json", function()` – Eduan Lenine Jan 23 '16 at 03:06
  • look that http://stackoverflow.com/questions/11297219/jquery-getjson-reading-a-local-file – Eduan Lenine Jan 23 '16 at 03:11
  • Do you use some application server: IIS, Apache, Nginx? – Eduan Lenine Jan 23 '16 at 03:16
  • Your reference to the Chrome question is almost certainly what is going on here. Did I read that MS adopted Chrome code for Edge? Whatever, the same thing is happening in both. And, yes, I use IIS for actual serving of my results, and that has always worked fine. Except that I have to change '...json' to .'...txt' for any JSON file! That I can live with. – Michael Broschat Jan 23 '16 at 14:54

0 Answers0