Phonegap让您通过简单的javascript界面调用gps等设备功能.
要解析JSON对象,您可以尝试以下两种方法:
干净的例子,
首先,包括jquery,会更容易
制作一个id为"searchButton"的按钮,一个id ="dataParsed"的div和一个id ="searchBox"的文本框
包括这段代码:
$('#searchButton').click(function() {
$.getJSON('http://api.alternativeto.net/software/'+$('#searchBox').val()+'/?count=15',
function(data) {
var items=data.Items;
// uncomment the line to see the structure of the json
//console.log(items);
var list = $('#dataParsed');
list.html("");
$.each(items, function(key, val) {
list.append($(document.createElement('p')).html(val.Name));
});
});
});
Run Code Online (Sandbox Code Playgroud)json + ajax + jquerymobile的示例:在phonegap wiki中阅读:
http://wiki.phonegap.com/w/page/36868306/UI%20Development%20using%20jQueryMobile
祝好运!:)
| 归档时间: |
|
| 查看次数: |
19600 次 |
| 最近记录: |