JQuery RESTful GET an object

I am looking for a way to get data from a url.  The url is a RESTful service and it is posting information about an employee.  The URL accepts one parameter, the employee id.  So knowing that, how would I build the Jquery so that it could pull that record and be able to parse the information to the text fields on a page.  SO in essence, the url could be http://employeeinfo/empid?=111

It would parse the following information once it pulls the RESTful call:

Employee ID
Employee First Name
Employee Last Name
Employee Department ID
Employee Street Address
Employee Zip code
Employee State
Employee Phone Number
VBBRettAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
Let's say that on your site, visitors arrive at "info.php", which in turn emits the javascript code to "consume" the service.  Since this is an third-party service (meaning the domain is different from your site's), you need to  send a header in "info.php" that tells the browser, "it is OK to make a request to the service site, even though it is 'external'." (More info at https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS).

So, info.php will look similar to:
<?php
header('Access-Control-Allow-Origin: http://theServiceSite.com');
?><html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript">
var emp_id=12;
$(function(){
    $.ajax({
            type: 'GET',
            url: "http://theServiceSite.com/employee/" + emp_id,
            dataType: "json",
            crossDomain: true,
            cache: false,
            success: function (data) {
                $('#result').text( JSON.stringify(data) );
            },
            error: function (jq, st, error) {
                alert(error);
            }
        });
});
</script>
</head>
<body>
<div id="result"></div>
</body>
</html>

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.