I just set up a fresh Drupal 7 site and created 50 articles with the Devel module.
Everything seems to work fine when using a browser, but I can't get the site to return json when using jQuery's ajax function.
I have all necessary permissions granted.

Browser (Chrome, Firefox), also cURL from command line:
http://mysite.local/node.json works fine
http://mysite.local/node/1.json works fine

jQuery (see code below):
http://mysite.local/node.json returns "404 file not found"
http://mysite.local/node/1.json returns the full html page, as if I requested http://mysite.local/node/1

jQuery ajax:

$.ajax({
  url: "http://mysite.local/node.json", // I have tried many, many things here. none return json.
  type: "GET",
  contentType: "application/json",
  type: "json",
  success: function(result) {
    console.log(result);
  }
});

Comments

eterps’s picture

Category: bug » support

EDIT: looks like it's a problem with my jQuery code. I tried $.getJSON() instead of .ajax() and now it works as expected.

theflowimmemorial’s picture

Status: Active » Closed (fixed)

Closing as fixed since it was a user error.

theflowimmemorial’s picture

Issue summary: View changes

added code tags around jquery snippet