3

我正在尝试在我的英特尔 XDK 项目中使用 codeigniter 来处理后端数据

我在 index.html 中有以下表格:

<form method="POST" class='ajax'>
    <input type="text" name="user" />
    <input type="password" name="password" />
    <input type="submit" value="send" /> 
</form>

当我尝试使用我的 js 函数访问控制器时,我得到了找不到文件的状态:

$('form.ajax').on('submit', function(){
var that = $(this),
url = "../../controllers/welcome.php";
method = that.attr("method"),
data = {};

that.find("[name]").each(function(index, value){
    var that = $(this),
    name= that.attr("name");
    value = that.val();
    data[name] = value;
});

$.ajax({
    url:url,
    type:method,
    data:data,
    success: function(response){
        console.log(response);
    }
});

});

url 路径指向该文件,但它仍然显示状态为 404:localhost:58889/http-services/emulator-webserver/ripple/userapp//C/xampp/htdocs/my_project_folder/application/controllers/welcome.php

我是否必须在我的 htaccesses 和配置文件中设置一些东西,就像在网站中一样?

还有一件事,我的 XDK 项目位于应用程序内的视图文件夹中

提前致谢

4

1 回答 1

0

您在 ajax 调用 (../../controllers/welcome.php) 中引用的文件只能在向浏览器提供页面的 Web 服务器的上下文中工作。这不是 HTML5 混合应用程序的工作方式,没有“网络服务器”(即使错误消息看起来好像有一个)。

您需要提交到 Web 服务器,在这种情况下,您需要指定该 Web 服务器的名称。在 HTML5 混合应用程序中,您的应用程序中的 index.html 页面对于设备来说是“本地的”,它不是由 Web 服务器通过网络提供的,因此它不是该域或上下文的一部分。

希望我说的有道理...

于 2014-03-31T21:17:43.017 回答