Here is my final code.
it is showing me the alerts but is not setting any value on the form
function getContactDetails()
{
var lookUpObjectValue = Xrm.Page.getAttribute("inmate_lookupbookingscree").getValue();
if ((lookUpObjectValue != null))
{
var lookuptextvalue = lookUpObjectValue[0].name;
var lookupid = lookUpObjectValue[0].id;
//alert(lookupid);
var serverUrl = Xrm.Page.context.getServerUrl();
//The XRM OData end-point
var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";
//var odataSetName = "ContactSet";
var odataSelect = serverUrl + ODATA_ENDPOINT + "/" + "(guid'" + lookupid + "')";
//alert(odataSelect);
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
datatype: "json",
url: odataSelect,
beforeSend: function (XMLHttpRequest) { XMLHttpRequest.setRequestHeader("Accept", "application/json"); },
success: function (data, textStatus, XmlHttpRequest) {
var result_contact= data.d;
//alert(result_contact.AccountNumber);
//replace the fields with the fields on your entity
Xrm.Page.getAttribute("inmate_firstname").setValue(result_contact.inmate_firstname);
Xrm.Page.getAttribute("inmate_lastname").setValue(result_contact.inmate_lastname);
},
error: function (XmlHttpRequest, textStatus, errorThrown) { alert('OData Select Failed: ' + odataSelect); }
});
}
}