0

I am charged with building a native mobile app for my company. Because I do not know Ojective-C, Java, or other native language, I plan to build the app with Web languages (html, js, web storage, etc) and compile it with the Cordova framework.

I have built many simple apps this way and it works very well, but none of my apps have relied on remote data.

I am not necessarily looking for code help, rather I need references.

How do apps like Facebook Mobile and others like it send and receive data from its app?

Please help get me going.

Tithos
  • 1,191
  • 4
  • 17
  • 40
  • 1
    Traditionally, via HTTP. You should first look at how HTTP commands (mostly POST and GET) work, how to use Websockets to establish continuous connection. If you use JavaScript, you need to learn principles of AJAX and how to implement it using js. – Alex Salauyou Apr 05 '14 at 21:40
  • I am good with AJAX. I have not worked with Websockets. Any good guides to learn? – Tithos Apr 05 '14 at 21:49
  • For me, Wikipedia was quite enough. You better search for a Websocket package that will suit the server you're using. Often, such package have both server-side packages and .js files that you just link in your html. For example, if you use node.js server, just install socket.io package and read its docs. – Alex Salauyou Apr 05 '14 at 21:54

1 Answers1

0

You can use jQuery & Ajax to send and receive data through app. You can interact with server scripts like php or ASP with ajax. There are plenty of resources for this.

A simple ajax request can be like

$.ajax({
        url: "http://www.example.com/test.php",
        type: "post",
        data: values,
        dataType: json,
        success: function(data){
            alert("success");
            $("#result").html('Submitted successfully');
        },
        error:function(){
            alert("failure");
            $("#result").html('There is error while submit');
        }
    });

You have to deal with how you will send response from server to app. Like in this example it's expecting a json reply.

View this link, this might help you

jQuery Ajax POST example with PHP

And as I said there are plenty of resources on net, just search in Google for jQuery ajax examples.

Community
  • 1
  • 1
AtanuCSE
  • 8,832
  • 14
  • 74
  • 112