I have two functions in my js file. Each function is used to fetch data from list. The first function is called as:

jQuery(document).ready(function () {
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', getSWDocs);
getSWDocsSuccess = function () {

var listItemEnumeratorlistReady = SFWData.collListItems.getEnumerator(),
   count = collListItems.get_count();

var listItemInfo = '';
DocList = new Array();

while (listItemEnumeratorlistReady.moveNext()) {
    swItem = listItemEnumeratorlistReady.get_current();
    var tempArray = new Array(4);

    tempArray[0] = documentType;
    tempArray[1] = swItem.get_item("FileRef");
    tempArray[2] = swItem.get_item("Title");
    tempArray[3] = swItem.get_item("SWSortOrder");


    var serviceType = $('#pagetype').val();

The second function is called in the success method of this function. There are other functions that have a dependency on this function and so I have called this function before the dependent functions. But still the caml query fired does not invoke the success function even if there is no issue.

  • 2
    I'm a bit confused, you use SOD to wait for sp.js then you call getSWDocs, but in this file you define getSWDocsSuccess ... does this mean getSWDocs calls getSWDocsSuccess? – eirikb Feb 19 '15 at 8:59
  • @Mancy You have specified getSWDocs as a callback method while you have implemented getSWDocsSuccess(). – nbi Feb 19 '15 at 9:24


SP.SOD.executeFunc('sp.js', 'SP.ClientContext', getSWDocs);


SP.SOD.executeFunc('sp.js', 'SP.ClientContext', getSWDocsSuccess);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.