<p>Try changing the url from "/actions/entries/saveEntry" to "/actions/entries/save-entry"</p>

CC BY-SA 4.0
2019-05-13T13:46:09.313Z
2019-05-13T13:46:09.313Z
Arjan
<p>I'm trying to update an entry on the front end with a click and without a form. I'm a bit new with AJAX but would love to simply put a new title for the entry that the button relates to. I'm currently getting <code>500 Internal Server Errors</code> when trying.</p>

<pre><code>{% for entry in currentUserSubmissions %}
  {{ entry.title }}
  {{ entry.submissionUrl }}
  &lt;a class="btn btn-approve btn-primary" data-id="{{ entry.id }}"&gt;Approve&lt;/a&gt;
{% endfor %}
</code></pre>

<p>This is my AJAX</p>

<pre><code>{% js at endBody %}

  $('.btn-approve').on('click', function() {

    var entryId = $(this).data('id');
    var data = {
        value: entryId,
        name: 'entryId',
        title: 'hello test'
    };
    var tokenName = '{{ craft.app.config.general.csrfTokenName }}';
    data[tokenName] = '{{ craft.app.request.csrfToken }}';

    // send ajax request
    $.ajax({
      method: "POST",
      dataType: "json",
      url: "/actions/entries/saveEntry",
      data: data,
      headers: {'Content-Type': 'application/x-www-form-urlencoded'},
      success: function (data) {
        console.log('success', data);
      },
      error: function (error) {
        console.log('error', data);
      }
    });
  });
{% endjs %}
</code></pre>

<blockquote>
  <p>/actions/entries/saveEntry 500 (Internal Server Error)</p>
</blockquote>

CC BY-SA 4.0
2019-05-13T12:13:03.943Z
What does your logs say? `storage/logs/web.log`
Jørgen
<templating><ajax>
AJAX Update Entry (500 Internal Server Error)
# AJAX Update Entry (500 Internal Server Error)

(Asked by: username_0 on 2019-05-13)

I'm trying to update an entry on the front end with a click and without a form. I'm a bit new with AJAX but would love to simply put a new title for the entry that the button relates to. I'm currently getting 500 Internal Server Errors when trying.
{% for entry in currentUserSubmissions %}
  {{ entry.title }}
  {{ entry.submissionUrl }}
  Approve
{% endfor %}

This is my AJAX
{% js at endBody %}

  $('.btn-approve').on('click', function() {

    var entryId = $(this).data('id');
    var data = {
        value: entryId,
        name: 'entryId',
        title: 'hello test'
    };
    var tokenName = '{{ craft.app.config.general.csrfTokenName }}';
    data[tokenName] = '{{ craft.app.request.csrfToken }}';

    // send ajax request
    $.ajax({
      method: "POST",
      dataType: "json",
      url: "/actions/entries/saveEntry",
      data: data,
      headers: {'Content-Type': 'application/x-www-form-urlencoded'},
      success: function (data) {
        console.log('success', data);
      },
      error: function (error) {
        console.log('error', data);
      }
    });
  });
{% endjs %}


/actions/entries/saveEntry 500 (Internal Server Error)

**Tags:** templating, ajax

> **Comments:**
> **username_1**: What does your logs say? `storage/logs/web.log`  

---

## 1 answers

### Answer by username_2 on 2019-05-13. Score: 1

Try changing the url from "/actions/entries/saveEntry" to "/actions/entries/save-entry"


---

