jqueryajaxcordovajquery-mobile

Should I use jQuery Ajax API in jQueryMobile?


I am making a Mobile web application, with HTML5, CSS3, JavaScript, and jQueryMobile and warping it with Phonegap.

I am new in all the web thing, and I was wondering, when I use the jQueryMobile for the UI, can I use the jQuery API for Ajax calls, or does jQueryMobile has it's own tools for that.

I need to use Ajax, to interact with an external web-service, I will be fetching(get) and updating(get/post) from a database.

In other words, does the jQueryMobile supports all the jQuery API, or do I have also to include the jQuery separately in my application.


Solution

  • jQuery function $.ajax is standard when creating an AJAX call with jQuery / jQuery Mobile.

    Working jsFiddle example: http://jsfiddle.net/Gajotres/jLdFj/

    $('#index').live('pagebeforeshow',function(e,data){ 
        $.ajax({url: "http://api.themoviedb.org/2.1/Movie.search/en/json/23afca60ebf72f8d88cdcae2c4f31866/The Goonies",
            dataType: "jsonp",
            jsonpCallback: 'successCallback',
            async: true,
            beforeSend: function() {
                $.mobile.showPageLoadingMsg(true);
            },
            complete: function() {
                $.mobile.hidePageLoadingMsg();
            },
            success: function (result) {
                ajax.parseJSONP(result);
            },
            error: function (request,error) {
                alert('Network error has occurred please try again!');
            }
        });         
    });
    

    Few things to consider: