I have this code :
$.ajax({
type:'POST',
url:'/store',
processData: false,
contentType: false,
data: formData,
async: false,
success: function (response) {
if(JSON.parse(response).status != 'Failure'){
console.log(JSON.parse(response).comment)
widget.attr("data-selection-id", JSON.parse(response).comment.id)
removeSelection()
}
}
});
This code started working after adding async: false
. It was strange because sometimes the attribute was added and sometimes it was not. Even if I tried to perform another action on the element, such as .hide()
, the effect was the same. I also tried, for example, displaying the message with the ID from the response, and that always worked correctly. As I wrote before - at the moment it works, but disabling async makes the application run terribly slow, and this is a problem for me. Do you have any other ideas how I can solve this problem?
I would like that every time after send request, the returned id is stored as a data attribute, but without async:false