Its it possible to use ajax to post a Web to lead form instead of the standard Web form created by sugar for posting enquires to leads.
Any help much appreciated.
Yes, you can always create a form of your liking and then simply POST the data to the REST v10 API (or even the older SOAP API).
To create a Lead, it would simply require you to use a POST to the endpoint /rest/v10/Leads with a JSON payload in the body that represents a name/value pairing of the fields you wish to populate on the record.
Thanks Angel, as newbie to that side of programming do you have any code examples that I can tinker with?
If you are just starting out with the Sugar API, I would urge you to take a look at the Sugar Developer Guide, found here:
Further to the above, I would encourage you to visit our Developer Blog at http://developer.sugarcrm.com
As for your particular scenario, you'll need to essentially cause your code to submit a minimum of two web requests to the Sugar API. The first, to the endpoint /rest/v10/oauth2/token will require that you provide a JSON payload in the body with some parameters, one of which is the Sugar user/pass combo to be used to access the API and in turn, Sugar.
If successful, that endpoint will return some OAuth tokens. You'll need the access_token for any subsequent calls to the API, namely the one that would be used to insert the data into the Leads module. Typically it is /rest/10/Leads, with a JSON payload that represents the field name/value pairing you want.
The manner in how you actually issue the web requests, or interact with API, will vary on the language you are using. Here is an example of the latter part of the process using PHP:
Retrieving data ...