3

I'm trying to use codeigniter in my intel XDK project to process the back-ending data

i have the following form in the index.html:

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

i'm getting the status of file not found when I try to access the controller with my js function:

$('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);
    }
});

});

the url path leads to the file, but it still shows status a 404 to: localhost:58889/http-services/emulator-webserver/ripple/userapp//C/xampp/htdocs/my_project_folder/application/controllers/welcome.php

do I have to set something in my htacceess and config files, as in a website?

one more thing, my XDK project is in the view folder inside application

thanks in advance

krisrak
  • 12,882
  • 3
  • 32
  • 46

1 Answers1

0

The file you are referencing in your ajax call (../../controllers/welcome.php) will only work in the context of a web server that is providing the pages to a browser. That's not how an HTML5 hybrid app works, there is no "web server" (even though the error message makes it seem like there is one).

You need to submit to a web server, in which case you need to specify the name of that web server. In an HTML5 hybrid app the index.html page in your app is "local" to the device, it is not being served over the net by a web server, so it is not part of that domain or context.

I hope what I'm saying makes sense...

xmnboy
  • 2,314
  • 2
  • 14
  • 31
  • thanks man, It makes perfect sense. I already developed an app with xdk and I know what you're talking about, but since I'm trying to work with a framework, I kind of expected it to work like a website one question though: once I get the data in the web-server, I can use codeigniter models and controllers functions to handle it normally, right? – user3479468 Apr 01 '14 at 23:17
  • Yes, you can use whatever you like on your web-server to manipulate the data passed to it from your XDK client app -- data passed using a PUT or websockets or... :) – xmnboy Jun 09 '14 at 05:49