This is a sample code we use to submit entries from webpage to CRM. Hope this helps:
function CreateWebLeadInCRM(SourceCampaignName, Email, MobilePhone, FirstName, LastName, CompanyName){
var webLead = new Object();
//Add Source Campaing name
if(SourceCampaignName != null)
webLead.sof_sourcecampaign = SourceCampaignName;
//Add Email
if(Email != null)
webLead.sof_Email = Email;
//Add Mobile phone
if(MobilePhone != null)
webLead.sof_MobilePhone = MobilePhone;
//Add First name
if(FirstName != null)
webLead.sof_FirstName = FirstName;
//Add Last name
if(LastName != null)
webLead.sof_LastName = LastName;
//Add Company name
if(CompanyName != null)
webLead.sof_CompanyName = CompanyName;
var jsonwebLead = JSON.stringify(webLead);
var createwebLeadReq = new XMLHttpRequest();
createwebLeadReq.open("POST", "http://SERVER/ORG/XRMServices/2011/OrganizationData.svc/sof_webleadSet", true, "USERNAME", "PASSWORD");
createwebLeadReq.setRequestHeader("Accept", "application/json");
createwebLeadReq.setRequestHeader("Content-Type", "application/json; charset=utf-8");
createwebLeadReq.onreadystatechange = function () {
createwebLeadReqCallBack(this);
};
createwebLeadReq.send(jsonwebLead);
Ugly thing about this approach is that you have to save your password inside your javascript function, which is not really safe approach.. On the other hand you should only allow this user to insert entries to only one custom table without possibility to do anything else inside your CRM. This way you could manage what happens if you get spammed by the bots.