Hello,
I have been using Javascript CSOM via SharePoint Pages that are hosted on SharePoint Server. This works well.
I was wondering it it is possible to create a simple HTML Page outside SharePoint with necessary CSOM code and access the SharePoint site?
I want to run this page directly from my Windows Explorer or host this HTML into some other technology like – Apache / PHP. (I can download the required JS files from SP_ROOT folder and distribute it on Apache/PHP)
Thanks,
Kamlesh
After pulling my hair out for hours because none of the examples online were working for me in SharePoint 2013, I discovered (in an answer to this question: http://sharepoint.stackexchange.com/questions/199508/jsom-sp-clientcontext-returning-error)http:s// that 2013 uses the same files, but in a different location:
src=”/_layouts/15/init.js”
src=”/_layouts/15/MicrosoftAjax.js”
src=”/_layouts/15/sp.core.js”
src=”/_layouts/15/sp.runtime.js”
src=”/_layouts/15/sp.js”
I hope this helps someone else avoid hours of frustration.
(Many thanks to the poster of this question, who found his/her own answer after no one else knew the answer: http://sharepoint.stackexchange.com/questions/199508/jsom-sp-clientcontext-returning-error)
A bare minimum is required:
<!DOCTYPE html>
<%@ Page language="C#" %>
<%@ Register Tagprefix="SharePoint"
Namespace="Microsoft.SharePoint.WebControls"
Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<
html
>
<
head
>
<!-- the following 5 js files are required to use CSOM -->
<
script
src
=
"/_layouts/1033/init.js"
></
script
>
<
script
src
=
"/_layouts/MicrosoftAjax.js"
></
script
>
<
script
src
=
"/_layouts/sp.core.js"
></
script
>
<
script
src
=
"/_layouts/sp.runtime.js"
></
script
>
<
script
src
=
"/_layouts/sp.js"
></
script
>
<!-- include your app code -->
<
script
src
=
"app.js"
></
script
>
</
head
>
<
body
>
<
SharePoint:FormDigest
ID
=
"FormDigest1"
runat
=
"server"
></
SharePoint:FormDigest
>
</
body
>
</
html
>