$。阿贾克斯()上的PhoneGap [英] $.ajax() on phonegap

查看:175
本文介绍了$。阿贾克斯()上的PhoneGap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都知道的的PhoneGap 的与 $一个例子。阿贾克斯()中的 github上的为Android?我已阅读JSONP或CORS,但我只工作从Twitter请求数据。

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.

推荐答案

它是通过jQuery Mobile的非常容易。你可以用正常的Ajax和JSON的点点做你的工作。我做了与PHP服务器。在这里,样品code,

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,

通过jQuery的发送请求到服务器。

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*/
                        }
       });

在PHP服务器上的文件,

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) . ');';
?>

这篇关于$。阿贾克斯()上的PhoneGap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆