How to make an ajax call using jQuery Mobile

mmpd used Ask the Experts™
Hello and thank you for helping me.

I am developing a jQuery Mobile application that needs to make an ajax call to an OData service.  I am stumped on how to do this. has made a public OData service available for testing.  The uri is:

Using LinqPad I can successfully connect to this service and I get the following results back:
Food, Beverages and Electronics.

Will you please provide a short snippet of code using jQuery Mobile, the jQuery Mobile apis and ajax that will demonstrate how to make this call and return the results?

Thank you very much
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Data Scientist
Most Valuable Expert 2014
Because you're dealing with data on another domain, you'll need a server side script to fetch the data. I'm including a php script.

Here is a sample jquery ajax call that returns the categories:

<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8"/>


    <script src=""></script>
           var path = "";
          $.get("getfile.php", {u:path}, function(data){
            var xmlDoc = $.parseXML(data);
            var content = $(xmlDoc);
              var curr = $(this);
              var title = curr.children("title").text();
              var entryItem = $("<div/>", {
                className : "entryItem"
                }); // end find each function
            }); // end .get function
        <div id="results"></div>


Open in new window

and the php file: save as getfile.php in same directory

  if (isset($_GET["u"])){
     $file = file_get_contents($_GET["u"]);
     if (!$file) die("there was an error");
     echo $file; 

Open in new window

Kyle HamiltonData Scientist
Most Valuable Expert 2014

Here is the result of the above code:
Kyle HamiltonData Scientist
Most Valuable Expert 2014

You could also look into $.mobile.changePage, which will enable jquery mobile transitions if you want, but you'll still probably need the php 'cause of the same domain restriction.


Thank you very much.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial