将 ajaxified Webpart 插入现有 MOSS 站点

发布于 2024-08-28 16:43:47 字数 366 浏览 3 评论 0原文

我需要编写一个 Web 部件,其目的是异步获取一些文档并将它们显示到现有页面中。不幸的是,我必须面对很多限制,到目前为止,我寻找解决方案的努力似乎毫无用处。

1) 我无法使用 Microsoft asp.net ajax
2)我必须使用Jsonp,因为被调用的服务(页面,无论什么......)位于站点的域之外。这不是什么大问题。
3) 我无法更改现有的页面代码,因此无法引用外部库,例如 JQuery。
4)出于同样的原因,我无法在 window.onLoad 事件上调用我的方法,所以这里的问题是:如何在触发我的 ajax 调用之前确保所有内容都已正确加载?
5)由于同一个webpart的多个实例可以放置到同一个页面中,那么各个js函数之间是否可能存在一些冲突?

I need to code a webpart which purpose is to asynchronously fetch some documents and display them into an existing page. Unfortunately I have to face a lot of rescritcions and my struggle to find a solution seems useleess so far.

1) I cannot use Microsoft asp.net ajax
2) I must use Jsonp because the called service (page, whatever...) is outside the site's domain. That's not a big problem.
3) I have no possibility to alter the existing page code, so I cannot reference an external library such as JQuery.
4) For the same reason I have no possibility to call my methods on the window.onLoad event, so here the question is: how can I be sure that everything is correctly loaded before triggering my ajax call?
5) Since several instances of the same webpart can be placed into the same page, can there be some possible conflicts among the various js functions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

半葬歌 2024-09-04 16:43:47
  1. D'oh
  2. D'oh #2
  3. jQuery 只是本机 JavaScript 调用的包装器。如果可以的话,让他们放弃这个限制,因为如果你正在做任何远程复杂的事情,你就会因为浏览器兼容性而变得疯狂。
  4. 使用 _spBodyOnLoadFunctionNames.push(functionName) 来完成此操作。
  5. 完全取决于 JS 的引入。我们需要更多说明。
  1. D'oh
  2. D'oh #2
  3. jQuery is just a wrapper for native JavaScript calls. If you can, get them to waive this restriction because if you're doing anything remotely complex you're going to go insane over browser compatibility.
  4. Use _spBodyOnLoadFunctionNames.push(functionName) to accomplish this.
  5. Depends entirely on the JS coming in. We'd need more clarification.
纵情客 2024-09-04 16:43:47

您不能仅使用服务器端代码(例如WebClient)调用第3方页面吗?您可能需要为此调整网站的信任级别。

对于客户端,我相信您仍然可以将 jQuery 代码“注入”到标记中。
使用 Google 托管 jQuery 的最佳方式,但回退到我在 Google 上的托管库失败

<script type="text/javascript">
if (typeof jQuery == 'undefined')
{
    document.write(unescape("%3Cscript src='/path/to/your/jquery' type='text/javascript'%3E%3C/script%3E"));
}
</script>

Can't you just call the 3rd party page using server-side code (e.g., WebClient)? You may have to adjust the site's trust levels for this.

For client-side, I believe you can still "inject" the jQuery code into the markup.
Best way to use Google's hosted jQuery, but fall back to my hosted library on Google fail

<script type="text/javascript">
if (typeof jQuery == 'undefined')
{
    document.write(unescape("%3Cscript src='/path/to/your/jquery' type='text/javascript'%3E%3C/script%3E"));
}
</script>
树深时见影 2024-09-04 16:43:47

如何使用页面查看器 Web 部件显示托管在其他位置(即不在 SharePoint 服务器上)的页面?该页面可以为您检索文档。

What about using a page viewer web part to display the page that is hosted elsewhere (ie not on your SharePoint server)? That page could retrieve the documents for you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文