android - Posting data to server with jQuery -


so have basic cordova app created. added jquery , trying make request url. target post data, i'm testing method. problem response "failed load resource: server responded status of 404 (not found)", when open url browser, response displayed.

i've been @ day , half, i've gone through alot topics on internet , tried different things, couldn't job done. if have ideas great!

my goal create android app, in fill several fields text, save them on device, , when connected wifi tap button push data in file server. if have suggestions on other can use instead of cordova, i`d appreciate it.

edit - here code: said, plain app created cordova. index.html , default index.js @ end added ajax:

$.ajax({    type: 'get',    url: 'url',    headers: {      'access-control-allow-origin': '*'    },    success: function(response) {      console.log(response);    },    error: function(req, err) {      console.log(req);      console.log(err);    }  });
<!doctype html>  <html>    <head>    <link rel="stylesheet" type="text/css" href="css/index.css">    <title>hello world</title>  </head>    <body>    <div class="app">      <h1>apache cordova</h1>      <div id="deviceready" class="blink">        <p class="event listening">connecting device</p>        <p class="event received">device ready</p>      </div>    </div>    <script type="text/javascript" src="js/jquery.js"></script>    <script type="text/javascript" src="cordova.js"></script>    <script type="text/javascript" src="js/index.js"></script>  </body>    </html>

jquery provide way connect server.(i.e)http asynchronous http (ajax) request.all jquery ajax methods use ajax() method. method used requests other methods cannot used.

this simple method connect server.

$.ajax({
url: "test.html",
context: document.body
}).done(function() {
$( ).addclass( "done" );
});

use method.no need add headers in client side. please add in end support cross platform issues(cors).

[to know more please refer ][1]

http://api.jquery.com/jquery.ajax/


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -