Click here to Skip to main content
15,902,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I've a SharePoint Hosted App and its deployed to Root site. Using that App, I need to read items of specific list from all sub sites of that root site. My current Code:
 SP.SOD.executeFunc("sp.js", 'SP.ClientContext', function () {
    var hostsuburl = "Subsite URL goes here";
    var context = new SP.ClientContext(hostsuburl);
    var oList = context.get_web().get_lists().getByTitle("ResourceDetails");
    var camlQuery = new SP.CamlQuery();
    camlQuery.set_viewXml("<View><Query><Where><Eq><FieldRef Name='monthnumber'/><Value Type='Text'>" + CurrentMonth + "</Value></Eq></Where></Query></View>");
    this.collListItem = oList.getItems(camlQuery);
    context.load(collListItem, 'Include(ActualHours,AvailableHours,CostPerHour)');
    context.executeQueryAsync(function onQuerySucceeded(sender, args) {
    alert('Inside OnQuery succeeded');
 , function onQueryFailed(sender, args) {
      alert('Failed to get lists. Error:n1' + args.get_message());

When I deploy code, I'm getting into onQueryFailed function, and getting error as "Unexpected response data from server error". I've checked the CAML Query, It has no error. How can I get it done? Any help would be appreciated.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900