Skip to main content
added 59 characters in body
Source Link
Iman
  • 593
  • 9
  • 19

Use Below Pattern

$(document).ready(function () { ExecuteOrDelayUntilScriptLoaded(AddVisitorFunctionToRunWhenLoadIsFinished, "sp.js"); });



function createListItemFunctionToRunWhenLoadIsFinished() {

    var clientContext = SP.ClientContext.get_current();
    var oList = clientContext.get_web().get_lists().getByTitle('ITSTotalDashboard_logs');
        
    var itemCreateInfo = new SP.ListItemCreationInformation();
    this.oListItem = oList.addItem(itemCreateInfo);
         
    oListItem.set_item('Title', 'test');
 
        
    oListItem.update();

    clientContext.load(oListItem);
        
    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
$(document).ready(function () { ExecuteOrDelayUntilScriptLoaded(AddVisitor, "sp.js"); });



function createListItem() {

    var clientContext = SP.ClientContext.get_current();
    var oList = clientContext.get_web().get_lists().getByTitle('ITSTotalDashboard_logs');
        
    var itemCreateInfo = new SP.ListItemCreationInformation();
    this.oListItem = oList.addItem(itemCreateInfo);
         
    oListItem.set_item('Title', 'test');
 
        
    oListItem.update();

    clientContext.load(oListItem);
        
    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}

Use Below Pattern

$(document).ready(function () { ExecuteOrDelayUntilScriptLoaded(FunctionToRunWhenLoadIsFinished, "sp.js"); });



function FunctionToRunWhenLoadIsFinished() {

    var clientContext = SP.ClientContext.get_current();
    var oList = clientContext.get_web().get_lists().getByTitle('ITSTotalDashboard_logs');
        
    var itemCreateInfo = new SP.ListItemCreationInformation();
    this.oListItem = oList.addItem(itemCreateInfo);
         
    oListItem.set_item('Title', 'test');
 
        
    oListItem.update();

    clientContext.load(oListItem);
        
    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
Source Link
Iman
  • 593
  • 9
  • 19

$(document).ready(function () { ExecuteOrDelayUntilScriptLoaded(AddVisitor, "sp.js"); });



function createListItem() {

    var clientContext = SP.ClientContext.get_current();
    var oList = clientContext.get_web().get_lists().getByTitle('ITSTotalDashboard_logs');
        
    var itemCreateInfo = new SP.ListItemCreationInformation();
    this.oListItem = oList.addItem(itemCreateInfo);
         
    oListItem.set_item('Title', 'test');
 
        
    oListItem.update();

    clientContext.load(oListItem);
        
    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}