I'm trying to create ajax call to update single field in database. My code is:
$.ajax({
type: "POST",
url: 'http://localhost/test_project/dnkuh_stavke/editfield/1',
data: ({ name: 'dnkuh_stavke_order', value: '13', pk:'1' }),
success: function() {
alert('Success');
},
error: function() {
alert('Error occured');
}
});
Link and fieldname should be fine I guess (copied from source code), value is hardcoded for test purposes.
I can't get this work so please help with correct code.
@pivar you cant post data for updates or insertion if the link you are posting it to does not have the
CSRF token passed to it. The URL line in your code should look like this.
url: 'http://localhost/test_project/dnkuh_stavke/editfield/1?csrf_token=' + csrfToken,
I suspect this might be your issue since you did not provide a clear error response gotten from the request. If the above does not fix your issue please provide the server response you get.