context.executeQueryAsync it woked fine before with no problem and suddenly still always fail i don't know what are the reasons:

  <Sharepoint:ScriptLink runat="server" Name="SP.js" Localizable="false"  ID="s3"   
  <Sharepoint:ScriptLink runat="server" Name="SP.Core.js" Localizable="false"  
     ID="s1" LoadAfterUI="true"/>
  <Sharepoint:ScriptLink runat="server" Name="SP.Runtime.js" Localizable="false"  
     ID="s2" LoadAfterUI="true"/>
  <Sharepoint:ScriptLink runat="server" Name="SP.UI.Dialog.js" Localizable="false"  
     ID="s4" LoadAfterUI="true"/>
  <Sharepoint:ScriptLink runat="server" Name="CUI.js" Localizable="false"  ID="s5" 
  <Sharepoint:ScriptLink runat="server" Name="SP.UI.Rte.js" Localizable="false"  
     ID="s6" LoadAfterUI="true"/>

  <script type="text/javascript">

    var items;
    var web;

    function getItems2(camlQuery){

     var context = SP.ClientContext.get_current();
     web = context.get_web();
     var list = context.get_web().get_lists().getByTitle('listname');
     items = list.getItems(camlQuery, 'AllItems');

     context.executeQueryAsync(Function.createDelegate(this, onListDataSucceeded),   
     Function.createDelegate(this, onListDataFailed));  


    function onListDataSucceeded(sender, args) {

    function onListDataFailed(sender, args) {

    $(document).ready(function() {
        var camlQuery = ".....";
        ExecuteOrDelayUntilScriptLoaded(getItems2(camlQuery), "sp.js");



1 Answer 1


You can check why it is failing. In the failed function add this line to display the error message as an alert.

alert('Failed: \n' + args.get_message() + '\n' + args.get_stackTrace());

Your Answer

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

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