3

Anyone know an example of phonegap with $.ajax() in github for Android? I have read of JSONP or CORS but I have worked only requesting data from Twitter.

I just need to get my data server.

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
fdbazan
  • 39
  • 1
  • 7

2 Answers2

4

It is very easy through jquery mobile. You can do your job with normal Ajax and little bit of JSON. I done with php server. Here the sample code,

Sending request to server through jquery.

$.ajax({
          url: <your Server URL>,
          dataType: 'jsonp',
          jsonp: 'jsoncallback',
          timeout: 5000,
          success: function(data, status){
                             /*Process your response here*/
                        }
       });

In php server file,

<?php
$data="I am sending response to you";

/*you have to mention this callback compulsory*/

echo $_GET['jsoncallback'] . '(' . json_encode($data) . ');';
?>
Akilan
  • 1,707
  • 1
  • 16
  • 30
1

Check this URL. It will help you to load data from your data server.

Ajinkya
  • 22,324
  • 33
  • 110
  • 161