Field gets updated, not inserted into the table
Field gets updated, not inserted into the table
$.ajax({
type: "POST",
url: "/getName",
contentType: "application/json; charset=utf-8",
data: json,
dataType: "json",
headers: {
Accept: "*/*"
}
}).then(function(data) {
editor.field('account_name').set(data.end_user_name.toString());
console.log(editor.get('account_name'));
editor.submit;
});
In the above code, which i put inside a preSubmit, the console.log showed that the value of account_name is updated, yet nothing gets inserted into the table for that field
Am I doing something wrong? Can you change field values inside the presubmit?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
preSubmit
is not waiting on your Ajax call to complete, so it will have just continued while this Ajax call was completing. The old data was therefore probably used in the submit.You could use
async: false
to stop that from happening if that is what you want, although I would suggest that it would be more efficient to just do it at the server-side, reducing the number of Ajax calls to 1 rather than 2.The other thing is that
editor.submit;
does nothing in the above code. It is a method so you would need to call it, but if this is inpreSubmit
then, unless you have cancelled the previous submit (which isn't shown in the above code), then there would be no need to call it.Allan