It seems the current documentation is lacking in detailing the proper procedure for submitting forms via Ajax. Although there is The Entries POST API, it specifically discusses xml and lacks an example payload.
Upon further investigation, I discovered Wufoo's partially developed jQuery plugin wufoo/Wufoo-JQuery-API-Wrapper, which appears to only wrap $.get
and slightly modify error formats. The functionality for POST requests is still a work in progress.
In my attempts to interact with the API, I experimented with different formats such as:
{
"Field1": "first",
"Field2": "last",
"Field3": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="83e6eee2eaefc3e6fbe2eef3efe6ade0ecee">[email protected]</a>",
"Field4": "test messsage",
}
Despite referencing "POST parameters in name/value pairs" and the example
postAuthenticated(array('Field1' => 'Frank'));
, I attempted to send an array of arrays.
[
['Field1', 'first'],
['Field2', 'last'],
['Field3', '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="91f4fcf0f8fdd1f4e9f0fce1fdf4bff2fefc">[email protected]</a>'],
['Field4', 'test messsage']
]
Unfortunately, my formatting was incorrect, leading to the following response:
{
"Success": 0,
"ErrorText": "Errors have been <b>highlighted</b> below.",
"FieldErrors": [
{
"ID": "Field3",
"ErrorText": "This field is required. Please enter a value."
},
{
"ID": "Field4",
"ErrorText": "This field is required. Please enter a value."
}
]
}
If anyone has insights on how to properly structure these requests, it would be greatly appreciated. Perhaps individuals familiar with CurlService can decipher the documentation, as I have been unable to grasp it or locate any helpful examples online.