开发者

How can I GET information from a RESTful interface and use it in my Javascript code?

I've got a RESTful interface where the contents of a database are displayed. What I need is to connect on that interface by my Javascript code and retrieve information. To be more specific, the only information I have for the RESTful interface is its URL. I want to connect by my application over the internet to this URL and retrieve the requested information (for example all the information stored in the database for the item with id=1). I am using JQuery mobile because I am developing a mobile application for iPhone using PhoneGap. I think I might have to use JSON but I don't know where exactly. Can you please provide me with references on how to do this开发者_运维问答?


The answer is simpler than I thought, and the references can be found in here: JQuery official page

My problem was solved by the use of the following function:

var jqxhr = $.getJSON("example.json", function() {
        //functionality
    })

    // perform other work here ...

    // Set another completion function for the request above
    jqxhr.complete(function(){ alert("complete"); });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜