2

In my code, I have something like:

A = Backbone.Model.extend({
  // url : "http://localhost:3000/a"
  url : "https://localhost:3000/a"
});

var a = new A();
a.save();

When I use the http url, everything is fine and dandy; when I use the https url, however, I get the following error

{readyState : 0, responseText : "", status : 0, statusText : ""}

and firebug "net" tab shows 0 requests

Adding onto the weirdness, when I use fetch on two other models, both give "aborted" error but firebug shows requests made and failed, rather than 0 requests as above.

4

1 回答 1

1

Is your site being served from port 3000 on localhost via HTTPS?

If not, then this won't work by default. CORS prevents requests from being processed without extra work unless the protocol (http or https), the domain (all parts of it) and the port match.

于 2012-07-19T18:02:55.800 回答