<p>Answer to my question. I ended up making a form and printing out the post as JSON.</p>

<pre><code>$('#submitQuiz').on('click', function (e) {
  e.preventDefault();

  var testEntrySubmission = [
    {
      name: 'action',
      value: 'guestEntries/saveEntry'
    },
    {
      name: 'sectionId',
      value: '5'
    },
    {
      name: 'enabled',
      value: '1'
    },
    {
      name: 'redirect',
      value: '/'
    },
    {
      name: 'title',
      value: 'user name'
    },
    {
    'name':'fields[answers]',
    'value':''
    },
    {
      'name':'fields[answers][new1][type]',
      'value':'6'
    },
    {
      'name':'fields[answers][new1][enabled]',
      'value':'1'
    },
    {
      'name':'fields[answers][new1][fields][question]',
      'value':'John Smith'
    },
  ];

  $.post('http://mywebsite.dev/', testEntrySubmission, function(response) {
    if (response.success) {
      console.log('success')
    } else {
      // response.error will be an object containing any validation errors that occurred, indexed by field name
      // e.g. response.error.fromName =&gt; ['From Name is required']
      alert('An error occurred. Please try again.');
    }
  });
});
</code></pre>

CC BY-SA 3.0
2016-09-20T12:53:14.013Z
2016-09-20T12:53:14.013Z
Amos Whitewolf
<p>I'm trying to submit a guest entry by building a javascript array of objects to mimic a form submission and submit using ajax. I've managed to successfully submit the entry with just a title but when trying to add Matrix/Super Table rows I'm having no luck.</p>

<p>I've looked here <a href="https://github.com/engram-design/SuperTable/wiki/Updating-a-Super-Table-field-from-a-front-end-form" rel="nofollow">https://github.com/engram-design/SuperTable/wiki/Updating-a-Super-Table-field-from-a-front-end-form</a> to get ideas for how this should work.</p>

<p>Super table block handle is <code>answers</code> and the Super Table field I'm trying to submit is a plain text field with the handle <code>question</code>.</p>

<p>My current code is:</p>

<pre><code>$('#submitQuiz').on('click', function (e) {
  e.preventDefault();

  var testEntrySubmission = [
    {
      name: 'action',
      value: 'guestEntries/saveEntry'
    },
    {
      name: 'sectionId',
      value: '5'
    },
    {
      name: 'enabled',
      value: '1'
    },
    {
      name: 'redirect',
      value: '/'
    },
    {
      name: 'title',
      value: 'user name'
    },
    {
      name: 'answers[new1][fields][question]',
      value: 'fingers crossed'
    }
  ];

  $.post('http://mywebsite.dev/', testEntrySubmission, function(response) {
    if (response.success) {
      console.log('success')
    } else {
      // response.error will be an object containing any validation errors that occurred, indexed by field name
      // e.g. response.error.fromName =&gt; ['From Name is required']
      alert('An error occurred. Please try again.');
    }
  });
});
</code></pre>

CC BY-SA 3.0
2016-09-20T08:25:36.010Z
All of your custom fields are going to require a name that starts with `fields`. So, your `answers[new1][fields][question]` should probably be `fields[answers][new1][fields][question]`. You can find an example of a front-end Matrix fields input structure here: https://straightupcraft.com/articles/craft-cms-field-guide-twig?view=input
Ben Parizek
<matrix><ajax><json><guest-entries><plugin-supertable>
Creating a guest entry, with a Matrix field, using Ajax
# Creating a guest entry, with a Matrix field, using Ajax

(Asked by: username_0 on 2016-09-16)

I'm trying to submit a guest entry by building a javascript array of objects to mimic a form submission and submit using ajax. I've managed to successfully submit the entry with just a title but when trying to add Matrix/Super Table rows I'm having no luck.
I've looked here https://github.com/engram-design/SuperTable/wiki/Updating-a-Super-Table-field-from-a-front-end-form to get ideas for how this should work.
Super table block handle is answers and the Super Table field I'm trying to submit is a plain text field with the handle question.
My current code is:
$('#submitQuiz').on('click', function (e) {
  e.preventDefault();

  var testEntrySubmission = [
    {
      name: 'action',
      value: 'guestEntries/saveEntry'
    },
    {
      name: 'sectionId',
      value: '5'
    },
    {
      name: 'enabled',
      value: '1'
    },
    {
      name: 'redirect',
      value: '/'
    },
    {
      name: 'title',
      value: 'user name'
    },
    {
      name: 'answers[new1][fields][question]',
      value: 'fingers crossed'
    }
  ];

  $.post('http://mywebsite.dev/', testEntrySubmission, function(response) {
    if (response.success) {
      console.log('success')
    } else {
      // response.error will be an object containing any validation errors that occurred, indexed by field name
      // e.g. response.error.fromName => ['From Name is required']
      alert('An error occurred. Please try again.');
    }
  });
});

**Tags:** matrix, ajax, json, guest-entries, plugin-supertable
> **Comments:**
> **username_1**: All of your custom fields are going to require a name that starts with `fields`. So, your `answers[new1][fields][question]` should probably be `fields[answers][new1][fields][question]`. You can find an example of a front-end Matrix fields input structure here: https://straightupcraft.com/articles/craft-cms-field-guide-twig?view=input  

---

## 1 answers

### Answer by username_0 on 2016-09-20. Score: 0 | Accepted answer

Answer to my question. I ended up making a form and printing out the post as JSON.
$('#submitQuiz').on('click', function (e) {
  e.preventDefault();

  var testEntrySubmission = [
    {
      name: 'action',
      value: 'guestEntries/saveEntry'
    },
    {
      name: 'sectionId',
      value: '5'
    },
    {
      name: 'enabled',
      value: '1'
    },
    {
      name: 'redirect',
      value: '/'
    },
    {
      name: 'title',
      value: 'user name'
    },
    {
    'name':'fields[answers]',
    'value':''
    },
    {
      'name':'fields[answers][new1][type]',
      'value':'6'
    },
    {
      'name':'fields[answers][new1][enabled]',
      'value':'1'
    },
    {
      'name':'fields[answers][new1][fields][question]',
      'value':'John Smith'
    },
  ];

  $.post('http://mywebsite.dev/', testEntrySubmission, function(response) {
    if (response.success) {
      console.log('success')
    } else {
      // response.error will be an object containing any validation errors that occurred, indexed by field name
      // e.g. response.error.fromName => ['From Name is required']
      alert('An error occurred. Please try again.');
    }
  });
});


---

