SP服务 - 跨浏览器问题

时间:2014-02-12 11:04:00

标签: jquery xml web-services spservices

此代码在Firefox中完美运行,但在I.E 8.0中运行时,userPerm无法定义。

<script type="text/javascript">
$(document).ready(function() {

$(document).ready(function() {

$().SPServices({
 operation: "GetRolesAndPermissionsForCurrentUser",
 async: false,

 completefunc: function(xData, Status) {

 alert(xData.responseXML.xml);

 var userPerm = $(xData.responseXML).SPFilterNode("Permissions").attr("Value");
  alert("userPerm = " + userPerm);
  var nonAdminP = (33554432 & userPerm) == 33554432;
  alert("Non Admin Permissions == 33554432: " + nonAdminP);
  var adminP = userPerm == 9223372036854775807;
  alert("Admin Permissions: " + adminP);




 }
});

});

});
</script>

编辑:

这是我在打印时从I.E获得的回复

xData.responseText

http://i60.tinypic.com/33ufnt3.png

然而在Firefox中:

http://i62.tinypic.com/205rid.png

当我在两个浏览器中直接访问该页面时,我有完全访问权限...

编辑2:

刚刚发现:

http://support.microsoft.com/kb/896861

编辑3

Fiddler回复:

结果协议主机URL正文缓存内容类型进程注释自定义

1 200 HTTP sp-coll-bbs.our-company-ag.com /sites/000057/PropertyandSite/HealthSafety/Assets/SitRight.aspx 23,698 private,max-age = 0;到期日:2014年1月29日星期三08:00:51 GMT text / html; charset = utf-8 iexplore:6064
2 304 HTTP sp-coll-bbs.our-company-ag.com /sites/000057/SiteAssets/title.css 0 private,max-age = 0;到期日:2014年1月29日星期三08:00:52 GMT iexplore:6064
3 200 HTTP code.jquery.com /jquery-1.9.1.js 268,503 max-age = 315360000;到期日:2037年12月31日星期四23:55:55 GMT application / x-javascript; charset = utf-8 iexplore:6064
4 304 HTTP sp-coll-bbs.our-company-ag.com /sites/000057/SiteAssets/CP%20Information%20Page%20Icons/60-pandSS.png 0 private,max-age = 0;到期日:2014年1月29日星期三08:00:52 GMT iexplore:6064
5 200 HTTP code.jquery.com /ui/1.10.4/jquery-ui.js 436,883 max-age = 315360000;到期日:2037年12月31日星期四23:55:55 GMT application / x-javascript; charset = utf-8 iexplore:6064
6 200 HTTP code.jquery.com /ui/1.10.4/themes/smoothness/jquery-ui.css 32,042 max-age = 315360000;到期日:2037年12月31日星期四23:55:55 GMT text / css iexplore:6064
7 304 HTTP sp-coll-bbs.our-company-ag.com /sites/000057/SiteAssets/jquery.SPServices-0.7.0.min.js 0 private,max-age = 0;到期日:2014年1月29日星期三08:00:52 GMT iexplore:6064
8 304 HTTP sp-coll-bbs.our-company-ag.com /sites/000057/SiteAssets/default/CP_small.PNG 0 private,max-age = 0;到期日:2014年1月29日星期三08:00:52 GMT iexplore:6064
9 200 HTTP sp-coll-bbs.our-company-ag.com /_vti_bin/Webs.asmx 380 private,max-age = 0 text / xml; charset = utf-8 iexplore:6064
10 302 HTTP sp-coll-bbs.our-company-ag.com /_vti_bin/usergroup.asmx 175 private,max-age = 0 iexplore:6064
11 200 HTTP sp-coll-bbs.our-company-ag.com /_layouts/AccessDenied.aspx 3,821 private text / html; charset = utf-8 iexplore:6064

1 个答案:

答案 0 :(得分:0)

您是否尝试过指定 webURL 参数(在async参数之前)并指定您网站的完全限定域名或内容的相对路径?

$().SPServices({
    operation: "operationname",
    webURL: "/sitepath", // <-- right here
    async: false,
    completefunc: function (xData, Status) {
        ...do stuff...
    }
});

(语法参考:http://spservices.codeplex.com/wikipage?title=%24().SPServices

另外 - 为什么你有两份 $(文件).ready()?你应该能够移除内部的那个。