我正在通过将javascript和html文件上传到文档库来在Sharepoint 2013中构建SPA.我试图通过sp.js库访问上下文信息来获取当前用户信息.但我得到这个错误:
_spPageContextInfo is not defined
Run Code Online (Sandbox Code Playgroud)
在我的index.aspx文件中,我包含以下js:
<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>
Run Code Online (Sandbox Code Playgroud)
我还将它包含在index.aspx文件的顶部:
<%@ 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" %>
Run Code Online (Sandbox Code Playgroud)
在我的js文件中,我有以下代码:
$(document).ready(function() {
// wait for the sharepoint javascript libraries to load, then call the function 'Initialize'
ExecuteOrDelayUntilScriptLoaded(runCode, "sp.js");
});
function runCode() {
var userid= _spPageContextInfo.userId;
}
Run Code Online (Sandbox Code Playgroud)
应该提到我使用Angular JS构建应用程序,并使用Angular UI路由器库在页面之间导航.
文档库位于侧面集合中的子网站内.
例如
intra.xxx.xxx/xxx/index.aspx
有什么建议?
我正在尝试将nodejs用作我公共网站和网络内部服务器之间的一个层.
我正在使用express.js来创建一个简单的REST api.API端点应触发对Web服务的请求调用,并返回结果.
但是我的.get()函数内部的请求调用没有做任何事情.
我想从嵌套调用返回结果返回.
码:
// Dependencies
var express = require('express');
var bodyParser = require('body-parser');
var request = require('request');
//Port
var port = process.env.PORT || 8080;
// Express
var app = express();
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
// Routes
app.get('/invoice', function(req, res){
res.send('Express is workiung on IISNode')
});
app.get('/invoice/api/costumer=:customerId&invoice=:invoiceId', function(req, res){
res.send('Customer ID: ' + req.params.customerId + ' Invoice ID: '+ req.params.invoiceId)
var url = 'http://xxx/invapp/getinvoice?company='+req.params.customerId+'S&customerno=13968&invoiceno='+req.params.invoiceId+'';
request('http://www.google.com', function (error, response, body) {
res.send(body);
})
});
// Start server
app.listen(port); …Run Code Online (Sandbox Code Playgroud) 我正在使用node并get从第3方api 请求js到json对象。当我尝试parse数据时出现错误:
SyntaxError: Unexpected token
然后,我尝试解析前端应用程序中的数据,从而导致以下错误(请参见令牌后的空白):
SyntaxError: Unexpected token in JSON at position 294512
所以我试图通过邮递员运行它,看看有什么问题。返回的JSON似乎有效,并且我也通过JSON验证程序运行了我,没有出现问题。
在对结果进行更多调查之后,我发现一个属性(文档类型)在双qoutes内始终具有空白:
{
"F24434": {
"Posting Date": "29-10-12",
"Open": "No",
"On Hold": "",
"Document Type": " ",
"External Document No.": "",
"Due Date": "29-10-12",
"Description": "xxxx",
"Order No.": "",
"Currency Code": "DKK",
"Remaining Amount": "0",
"Original Amount": "0",
"Amount": "0",
"User ID": "xxx",
"Systemdato": "29-10-12",
"Entry No.": "607121",
"Vessel No.": "",
"Port No.": ""
}
}
Run Code Online (Sandbox Code Playgroud)
我不确定这是否会导致问题,还是其他原因?
不幸的是,我没有直接访问API的权限,因此无法更改数据的结构方式。
解决方案 事实证明,它是双引号内的空格。解决方案是在解析之前删除所有空格:
.replace(/\s/g, '');
我无法从Dockerfile编译nodejs打字稿应用程序。当我构建泊坞窗映像时,检查将其完全丢失dist文件夹。
Dockerfile:
# Template: Node.js dockerfile
# Description: Include this file in the root of the application to build a docker image.
# Enter which node build should be used. E.g.: node:argon
FROM node:latest
# Create app directory for the docker image
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app/dist
# Install app dependencies from package.json. If modules are not included in the package.json file enter a RUN command. E.g. RUN npm install <module-name>
COPY package.json /usr/src/app/
RUN npm install
RUN npm …Run Code Online (Sandbox Code Playgroud) 我正在将JSON结构中的值解析为Morris JS条形图.JSON值通过Ajax加载.问题是只有每一秒的值都加载到x行(xkeys)中.
我的代码:
<script>
$( document ).ready(function() {
$.ajax({
url: "http://intra.site.com/_vti_bin/ListData.svc/ExchangeRates?$orderby=Modified%20desc",
headers: { 'accept': 'application/json;odata=verbose', 'content-type': 'application/json;odata=verbose'},
success: function(data){
var params = {
element: 'myfirstchart',
data: [],
xkey: 'year',
ykeys: ['value'],
barColors: ['#f46813'],
labels: ['Rate']
};
data.d.results.forEach(function(element) {
var obj = { "year": element.ExchangeCross, "value": element.ApprovedRate };
params.data.push(obj);
});
Morris.Bar(params);
}
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
图表呈现正常,但缺少一些标签.我拍了一张截图.
关于如何解决这个问题的任何建议?
我在Google Chrome上遇到了一个奇怪的错误(版本53.0.2785.143).当我尝试打印页面的内容时,它包括一个表头两次.
表头只应在底部显示一次.
图片:
在不同的部分中,表头流过表行.
我正在使用打印媒体查询,以便只打印我的页面内容:
@media print {
table {
page-break-inside:auto
}
tr {
page-break-inside:avoid; page-break-after:auto
}
body * {
visibility: hidden;
}
.no-padding-small{
padding: 0!important;
}
.stage, .progress-indicator {
display: none;
}
#header{
display: none;
}
.fixed-menu{
display: none;
}
.printable * {
visibility: visible;
}
textarea, input[type], table, td, th, tr{
page-break-inside: avoid;
}
}
Run Code Online (Sandbox Code Playgroud)
有什么建议?
我已经把头撞到了墙上几天了.我正在尝试使用Angular js将项添加到Sharepoint中的列表中.
检索项目是顺畅的,但添加项目对我不起作用.
码:
spApp.controller('spListCtrl', function($scope, $http, $q) {
$http.post("https://tools.site.com/_api/lists/getbytitle('PersonalFilter')/items", {
'Title': 'TEST'
}, {
headers: {
'Accept': 'application/json; odata=verbose',
'X-RequestDigest': $("#__REQUESTDIGEST").val()
}
}).success(function(data, status, headers, config) {
console.log("YES");
}).error(function(data, status, headers, config) {});
});
Run Code Online (Sandbox Code Playgroud)
我之前用jQuery Ajax(以类似的方式)完成了这个,但我似乎找不到问题.
该脚本与调用的位置在同一站点上运行,因此不进行跨域调用.此外,它嵌入了脚本编辑器,因此直接在Sharepoint主页中运行.
有什么建议?
我试图通过将包含纬度/经度位置的字符串转换为数组来在 Google 地图上创建多边形标记。我遇到以下错误:
mc {message: "at index 0: not a LatLng or LatLngLiteral: in property lat: not a number", name: "InvalidValueError"
Run Code Online (Sandbox Code Playgroud)
当我在浏览器控制台中检查数组时,它看起来很好(索引[0]):
lat:"12.3394541791301"
lng:"55.59020913559151"
Run Code Online (Sandbox Code Playgroud)
该字符串具有以下结构:
'12.3394541791301,55.59020913559151, 12.3444451791347,55.5930451355941, 12.3808361791686,55.6099911356099,
Run Code Online (Sandbox Code Playgroud)
所以首先我将每一秒替换comma为;
当我用来split(";")创建数组时,我会循环并使用正确的键将其推入新数组:
s = s.replace(/([^,]+,[^,]+),/g,'$1;');
s = s.split(";");
for (var i = 0; i < s.length; i++) {
var lat = s[i].split(',')[0];
var lng = s[i].split(',')[1];
// Push to array which is used by Google Maps
denmarkLatLong.push({lat: lat, lng: lng})
}
Run Code Online (Sandbox Code Playgroud)
对于可能导致问题的原因有什么建议吗?
javascript ×5
angularjs ×2
node.js ×2
sharepoint ×2
arrays ×1
css ×1
docker ×1
express ×1
google-maps ×1
html ×1
jquery ×1
json ×1
morris.js ×1
rest ×1
typescript ×1