Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am running into something that I haven't really seen before, and I have been using this approach quite a bit lately for a variety of pages. SharePoint 2010 javascript using REST API to grab data:

getContent("http://myServer/sites/mySite/_vti_bin/ListData.svc/Announcements", thisCallback)

function getContent(whatURL, callback)
{
     var request = new Sys.Net.WebRequest();
     request.set_httpVerb("GET");
     request.set_url(whatURL);
     request.get_headers()["Accept"] = "application/json";
     request.add_completed(callback);
     request.invoke();
}

and parse json and process with callback. but now i am getting console error "Sys is undefined" and I am using the same approach within the same site on different pages and it works? any ideas? just for checking i would add a simple callback and it still doesn't work

function thisCallback(response, eventArgs)
{
      // wish i could get some results to work with
}

appreciated as always.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

just in case anyone else runs into this I figured out what was going on:

I usually create multiple custom aspx pages in SP2010 and never really ran into this issue before. When I do, I always add the scriptlink back in:

<SharePoint:ScriptLink name="SP.js" defer="true" runat="server" Localizable="false"/>

but it appears that you must also include a generic form tag for security reasons. when you create a blank aspx page its already there, guess I just happened to accidentally remove it on this page. After I wrapped everything in a simple generic form tag it all worked again (REST & SP JSOM):

<form id='form1' runat='server'>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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