2
4

2 回答 2

2

This has nothing to do with Backbone specifically. You are loading the page with a file:/// URL and the problem is an AJAX Cross Origin request.

There are ways around it - you could load your web pages through your server which is running the REST services. Alternatively, you could allow cross origin requests. I'll let you search for how to do that.

EDIT If you are developing a PhoneGap application, you will not have the issue once you actually run the application since it will not complain about cross origin requests. At that point it is a local app so the request is not cross-origin. The way to get around that at development time is the --allow-file-access flag which you said you could not get to work. You need to make sure to close any other open Chrome windows and then start a new instance with that flag.

于 2013-01-30T10:31:16.930 回答
1

You can use JSONP in your ajax call which allows cross origin requests

Read more at here and here

EDIT :

Using jsonp expects back a json object, and it does not work with xml. So mayb you need to wrap your XML into json before sending from the server, or parse your xml to json.

this, this and this may prove helpful :)

于 2013-01-30T12:02:45.577 回答