jquery - O365 SharePoint CEWP with Javascript Not Loading? -
i'm trying execute example using "etherson method" create web part javascript. want separate .html , .js files in custom library shown: files
if keep js inline, code works expected:
<!doctype html><html><head> <title></title> <script type="text/javascript"> $(function () { $.ajax({ url: "/moperations/_api/web/lists/getbytitle('demo list')/items", type: "get", headers: { "accept": "application/json;odata=verbose" }, }).success(function (data) { var listiteminfo = ""; $.each(data.d.results, function (key, value) { listiteminfo += "<strong>title: </strong>" + value.title + " <strong>description: </strong>" + value.description + "<br />"; }); $("#divhelloworld").html(listiteminfo); }); }); </script></head><body> <div id="divhelloworld">hello world!</div></body></html> but if reference external .js file, it's javascript doesn't exist (i.e. never gets called):
<!doctype html> <html"> <head> <meta charset="utf-8" /> <title></title> <script type="text/javascript" scr="https://mysite.sharepoint.com/moperations/webparts/simpleexample/simpleexample.js"></script> </head> <body> <div id="divhelloworld">hello worlds!</div> </body> </html> i verified path https://mysite.sharepoint.com/moperations/webparts/simpleexample/simpleexample.js correct.
what missing?
you need change "scr" "src" in html.
<script type="text/javascript" scr="your_js_file.js"></script> to
<script type="text/javascript" src="your_js_file.js"></script>
Comments
Post a Comment