asheefh mohammad

asheefh mohammad

  • NA
  • 343
  • 558

$.getScript not executing for second time

Oct 28 2019 1:41 AM
i am trying to upload multiple files to SharePoint list by using client-side scripting perhaps $.getScript() function executing only one time the second iteration it will not respond (any exceptions). i have tried enabling cash but no luck.
 
$.getScript(scriptbase + "SP.RequestExecutor.js", function () {
var createitem = new SP.RequestExecutor(_spPageContextInfo.webServerRelativeUrl);
 createitem.executeAsync({       url: _spPageContextInfo.webServerRelativeUrl + "/_api/web/lists/GetByTitle('" + listName + "')/items(" + id + ")/AttachmentFiles/add(FileName='" + file.name + "')",
    method: "POST",
    binaryStringRequestBody: true,
      body: binary,
   success: fsucc,
   error: ferr,
   state: "Update" });
function fsucc(data) {
   console.log(data + ' uploaded successfully : '+file.name);
  deferred.resolve(data); }
 function ferr(data) {
     console.log(fileName + "not uploaded error");
     deferred.reject(data); } });

Answers (2)