You can use this function (find in the JQueryContactEditor.js)
function createRecord(entityObject, odataSetName, successCallback, errorCallback) {
/// <summary>
/// Uses jQuery's AJAX object to call the Microsoft Dynamics CRM OData endpoint to
/// Create a new record
/// </summary>
/// <param name="entityObject" type="Object" required="true">
/// 1: entity - a loose-type object representing an OData entity. any fields
/// on this object must be camel-cased and named exactly as they
/// appear in entity metadata
/// </param>
/// <param name="odataSetName" type="string" required="true">
/// 1: set - a string representing an OData Set. OData provides uri access
/// to any CRM entity collection. examples: AccountSet, ContactSet,
/// OpportunitySet.
/// </param>
/// <param name="successCallback" type="function" >
/// 1: callback-a function that can be supplied as a callback upon success
/// of the ajax invocation.
/// </param>
/// <param name="errorCallback" type="function" >
/// 1: callback-a function that can be supplied as a callback upon error
/// of the ajax invocation.
/// </param>
//entityObject is required
if (!entityObject) {
alert("entityObject is required.");
return;
}
//odataSetName is required, i.e. "AccountSet"
if (!odataSetName) {
alert("odataSetName is required.");
return;
}
else
{ odataSetName = encodeURIComponent(odataSetName); }
//Parse the entity object into JSON
var jsonEntity = window.JSON.stringify(entityObject);
//Asynchronous AJAX function to Create a CRM record using OData
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
datatype: "json",
url: clientUrl + ODATA_ENDPOINT + "/" + odataSetName,
data: jsonEntity,
beforeSend: function (XMLHttpRequest) {
//Specifying this header ensures that the results will be returned as JSON.
XMLHttpRequest.setRequestHeader("Accept", "application/json");
},
success: function (data, textStatus, XmlHttpRequest) {
if (successCallback) {
successCallback(data.d, textStatus, XmlHttpRequest);
}
},
error: function (XmlHttpRequest, textStatus, errorThrown) {
if (errorCallback)
errorCallback(XmlHttpRequest, textStatus, errorThrown);
else
errorHandler(XmlHttpRequest, textStatus, errorThrown);
}
});
}
And in the HTML
//Create the CRM record
createRecord(contactObject, "ContactSet", ContactCreateCompleted, ContactCreateFailed);
Which you can find in the HTML file in the same folder under that SDK folder.
You just need to construct the contactObject.