javascript – The AJAX REST call from the POST to SharePoint list generates errors

I have difficulties with the AJAX implementation in JQuery to make REST calls to POST data to add items to my SharePoint list. Use & GET & # 39; to retrieve information does not pose any problem. Given the following form header information:

I use the following AJAX function to publish my data:

function submitListItems (listName, jsonObj, _async) {

var jsonObj .__ metadata = {type: GetItemTypeForListName (listName)};

// Update form summary for X-Request-Digest
UpdateFormDigest (_spPageContextInfo.webServerRelativeUrl, _spFormDigestRefreshInterval);

var baseRequest = {
url: "",
type: "",
contentType: "",
The data: ""
};

var request = baseRequest;
request.type = & # 39; POST & # 39 ;;
request.contentType = application / json; odata = verbose & # 39 ;;
request.data = JSON.stringify (jsonObj);
request.url = _spPageContextInfo.webAbsoluteUrl + "/ _api / web / lists / GetByTitle (" + listName + ") / items";
request.headers = {
ACCEPT: & # 39; application / json; odata = verbose & # 39;
& # 39; X-RequestDigest: $ ("#__ REQUESTDIGEST"). Val ()

};

returns $ .ajax (request);
};

This is constantly going to the Promise $ .ajax.fail () method instead of the Promise $ .ajax.done () method. When I look at the SharePoint list to which the data is sent, they are written correctly. However, when I look at the output of the console, it gives me the error:

{"readyState": 0, "status": 0, "statusText": "error"}

Originally, I had read that this could be due to the cross-domain display, but since it's an application hosted on SharePoint I do not see how that could be the case. I tried to add the line

UpdateFormDigest (_spPageContextInfo.webServerRelativeUrl, _spFormDigestRefreshInterval);

but that did not solve the problem. Does anyone have any suggestions?