0

ECMAScript is not working in SharePoint 2013 content editor web-part.Please let me know issue in the below code.

     <script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>
     <script src="https://code.jquery.com/jquery-1.11.0.min.js" type="text/javascript"></script>
     <script src="https://code.jquery.com/jquery-migrate-1.2.1.min.js" type="text/javascript"></script>

ExecuteOrDelayUntilScriptLoaded(filldata, "sp.js");

        <script type="text/javascript">
     var itemId = 49;
     var listItem;       
            var clientContext;
            function filldata() {

                this.clientContext = new SP.ClientContext.get_current();
                if (this.clientContext != undefined && clientContext != null) {

                    this.web = clientContext.get_web();
                    var list = web.get_lists().getByTitle("list name");
                    this.listItem = list.getItemById(itemId);               
                    clientContext.load(this.listItem);
     clientContext.executeQueryAsync(Function.createDelegate(this, this.onSuccess), Function.createDelegate(this, this.onFail)); // this statement not executing.
                }
            }

    </script>
4
  • Are you on a minimal download strategy page? You can tell if you are because your URL ending will look like this: '/_layouts/15/start.aspx#/SitePages/Page.aspx' instead of just '/SitePages/Page.aspx'
    – John-M
    Aug 29, 2014 at 19:31
  • Above code is working fine in application pages by adding below code. SP.SOD.executeFunc('sp.js', null, function () { // filldata(); });
    – Ganesha
    Aug 30, 2014 at 7:06
  • Generally i try to put in script editor webparts. You can try with that.
    – Amit
    Aug 30, 2014 at 12:31
  • Getting same problem with script editor also.
    – Ganesha
    Aug 30, 2014 at 16:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.