Skip to content
This repository was archived by the owner on Oct 23, 2019. It is now read-only.
This repository was archived by the owner on Oct 23, 2019. It is now read-only.

Jquery ajax client not working #36

@jeangui

Description

@jeangui

Hi,

First, thanks a lot for this usefull meteor package. I have been using it for some weeks up to now.
Currently I need to request the rest API with jquery ajax queries.

I have modified the collectionapi.js file in order to handler cross domain request like this :

CollectionAPI._requestListener.prototype._sendResponse = function(statusCode, body) {
  var self = this;
  self._response.statusCode = statusCode;
  self._response.setHeader('Content-Length', Buffer.byteLength(body, 'utf8'));
  self._response.setHeader('Content-Type', 'application/json');
  self._response.setHeader('Access-Control-Allow-Origin', '*');
  self._response.setHeader('Access-Control-Allow-Methods','POST, GET, OPTIONS');
  self._response.setHeader('Access-Control-Allow-Headers','X-Requested-With');
  self._response.write(body);
  self._response.end();
};

But still I don't manage to query the api with jquery ajax.

Here is the error I get in the chrome js console 👍

OPTIONS http://localhost:3000/collectionapi/players 501 (Not Implemented) jquery-2.1.1.min.js:4
k.cors.a.crossDomain.send jquery-2.1.1.min.js:4
n.extend.ajax jquery-2.1.1.min.js:4
(anonymous function) test.html:13
XMLHttpRequest cannot load http://localhost:3000/collectionapi/players. Invalid HTTP status code 501 test.html:1

What should I do ?

Thanks in advance for your help.

cheers,

@jeangui

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions