2016-09-27 2 views
3

는 셰어 포인트 온라인 앱 캘린더 목록에서 이벤트를 반복적으로 발생하는 얻으려고 노력하고 있고
XMLHttpRequest를로드 할 수없는지고 (URL)를 프리 플라이트에 대한 응답은 여기 (재)

hostWebUrl = decodeURIComponent(manageQueryStringParameter('SPHostUrl')); 
    function GetListData() { 
     var webUrl = hostWebUrl;// = "http://server/sitewhereyourlistexists"; 
     var listGuid = "{2000da75-8663-42d9-9999-ad855c54b4e0}" 


     // An XMLHttpRequest object is used to access the web service 
     var xhr = new XMLHttpRequest(); 
     var url = webUrl + "/_vti_bin/Lists.asmx"; 
     xhr.open("POST", url, true); 
     xhr.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); 
     xhr.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/GetListItems"); 

     // The message body consists of an XML document 
     // with SOAP elements corresponding to the GetListItems method parameters 
     // i.e. listName, query, and queryOptions 
     var data = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + 
      "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + 
       "<soap:Body>" + 
       "<GetListItems xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\">" + 
         "<listName>" + listGuid + "</listName>" + 
         "<query>" + 
          "<Query><Where>" + 
           "<DateRangesOverlap>" + 
            "<FieldRef Name=\"EventDate\"/>" + 
            "<FieldRef Name=\"EndDate\"/>" + 
            "<FieldRef Name=\"RecurrenceID\"/>" + 
            "<Value Type=\"DateTime\"><Today/></Value>" + 
           "</DateRangesOverlap>" + 
          "</Where></Query>" + 
         "</query>" + 
         "<queryOptions>" + 
          "<QueryOptions>" + 
           "<ExpandRecurrence>TRUE</ExpandRecurrence>" + 
          "</QueryOptions>" + 
         "</queryOptions>" + 
       "</GetListItems>" + 
       "</soap:Body>" + 
      "</soap:Envelope>"; 

     // Here we define what code we want to run upon successfully getting the results 
     xhr.onreadystatechange = function() { 
      if (xhr.readyState == 4) { 
       if (xhr.status == 200) { 
        var doc = xhr.responseXML; 
        // grab all the "row" elements from the XML results 
        var rows = doc.getElementsByTagName("z:row"); 
        var results = "Today's Schedule (" + rows.length + "):\n\n"; 
        var events = {}; 
        for (var i = 0, len = rows.length; i < len; i++) { 
         var id = rows[i].getAttribute("ows_FSObjType"); // prevent duplicates from appearing in results 
         if (!events[id]) { 
          events[id] = true; 
          var allDay = rows[i].getAttribute("ows_fAllDayEvent"), 
           title = rows[i].getAttribute("ows_Title"), 
           start = rows[i].getAttribute("ows_EventDate"); 
          var index = start.indexOf(" "); 
          var date = start.substring(5, index) + "-" + start.substring(2, 4); // get the date in MM-dd-yyyy format 
          start = start.substring(index, index + 6); // get the start time in hh:mm format 
          var end = rows[i].getAttribute("ows_EndDate"); 
          index = end.indexOf(" "); end = end.substring(index, index + 6); // get the end time in hh:mm format 
          results += date + " " + (allDay == "1" ? "All Day\t" : start + " to " + end) + " \t " + title + "\n"; 
         } 
        } 
        alert(results); 
       } else { 
        alert("Error " + xhr.status); 
       } 
      } 
     }; 

     // Finally, we actually kick off the query 
     xhr.send(data); 
    } 


같은 후 같은 코드를 사용하고이 유효하지 않습니다 이 함수를 선언문에서 호출합니다. 준비 섹션은 모든 데이터를 검색하는 것이 아니라, 내가 다음 "경위를 선택, 당신은 왼쪽 측면 패널의 올바른 요청을 클릭합니다
enter image description here

+0

안녕, 당신은 피들러를 설치 한 후 다시 POST를 실행 봤어? Fiddler는 훌륭한 네트워크 메소드 디버깅 도구이며 요청과 응답을 볼 수 있습니다. 테스트가 끝나면 다시 게시하여 도움을 드릴 수 있도록 도와주세요. – Daniel

+0

예, 지금이 코드를 어떻게 설치합니까? – Madhav

+0

그냥 앱을 열어 (Fiddler) 앱에서 POST를 실행하면 네트워크상의 픽업이 – Daniel

답변

0

다음과 같다 브라우저의 콘솔에서 볼 수있는 오프라인 오류가 있습니다 "오른쪽 상단 패널에 있습니다. 그런 다음 서로 다른 요청 및 응답 옵션 중에서 선택하십시오. 이

Fiddler

+0

okk, 위의 오류를 일으키는 것은 무엇입니까? – Madhav

+0

꽤 많은 사람들이 -> 그렇지 않으면 단지 서버에 대한 호출을 디버깅합니다. 내가 찾은 것을 다시 게시하면 도움을 더받을 수 있습니다. – Daniel

관련 문제