成员数据休息适配器不工作



我对EmberJS非常陌生。我正在尝试制作一个简单的Ember CRUD应用程序。我正在使用EmberData的REST适配器。REST适配器被配置为从CodeIgniter应用程序中提取数据。

我已经测试了CodeIgniter应用程序,它正在正确地提供数据

这是我的Ember代码(除了路线)

http://pastebin.com/pWrp6hRz

这是我的router.js文件

http://pastebin.com/MzqAjshJ

当我导航到/用户时,我会收到以下错误:

Error: assertion failed: Error while loading route:
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /users was not found on this server.</p>
</body></html>
, status: 404, statusText: Not Found} @ http://localhost/todo3/js/libs/ember-1.2.0.js:796

当我导航到/部门时,也会遇到类似的错误

有趣的是,如果我更改行

App.ApplicationAdapter = DS.RESTAdapter.extend();

App.ApplicationAdapter = DS.FixtureAdapter.extend();

并评论出

DS.RESTAdapter.reopen({
  url: 'http://localhost/service_r/index.php'
});

还添加了一些夹具数据(绝对不再进行更改)然后错误消失,我可以看到数据。

RestAdapter有什么问题?

我想我应该把这个作为答案发布:)谢谢投票!

我不熟悉RESTAdapter上的"url"属性。那有什么用?你不应该使用"名称空间"或"主机"属性吗?您可以在这里阅读有关RESTAdapter的信息:emberjs.com/api/data/classes/DS.RESTAdapter.html

服务器上似乎有问题,因为您得到的是404。正如错误消息所示。您应该使用"namespace"属性来确保您正在访问正确的serverurl。

编辑:Steve H已经在评论中发布了这个答案!

最新更新