-2

Anyone please suggest me some tutorial or share some useful to invoke webservice from javascript in Phonegap Android

4

1 回答 1

0
$(document).ready(function() {

$.ajax({
    type: "GET",
    url: "data.xml",
    dataType: "xml",
    success: function(xml) {          
        var items = parseXml(xml);
        doStuff(items);
    }
});
});

function parseXml(xml) {

var items = [];
$(xml).find("category").each(function() {
    items.push({
        name: $(this).find("name").text(), 
        value: $(this).find("value").text()
    });
});
return items;
}


function doStuff(items) 
{

//Do some javascript stuff with the response
alert(items[0].name);
alert(tiems[0].value);
}
于 2013-08-12T11:50:01.873 回答