错误:'Msn.VE.API.Globals.vemapinstances'为null或不是对象

时间:2011-12-07 22:00:10

标签: jquery

我想知道为什么我收到运行时错误:“错误:'Msn.VE.API.Globals.vemapinstances'为空或不是对象”在我的页面上运行javascript时。页面的html如下。我正在尝试弹出jquery对话框,其中有一个控件和一个取消按钮供用户进行交互。 “divFollow”类包含用户将与之交互的一种控件类型,“divFriend”类包含用户与之交互的另一个控件。下面,用户与之交互的这些控件位于表格中。有帮助吗?谢谢!

<script type="text/javascript">
$(document).ready(function () {
    $('.FriendControl').click(showDialogFriend);
    $('.FollowControl').click(showDialogFollow);
    $('#ButtonFriendClose').click(closeDialogFriend);
    $('#ButtonFollowClose').click(closeDialogFollow);

    $('.divFollow').dialog({ height: 350,
        width: 550,
        resizable: false,
        modal: true,
        position: 'center',
        autoOpen: false,
        overlay: { opacity: 0.5, background: 'black' }
    });
    $('.divFriend').dialog({ height: 350,
        width: 600,
        resizable: false,
        modal: true,
        position: 'center',
        autoOpen: false,
        overlay: { opacity: 0.5, background: 'black' }
    });
}
)

//function to show dialog Friend and Follow   
var showDialogFriend = function () {
    //if the contents have been hidden with css, you need this
    $('.divFriend').show();
    //open the dialog
    $('.divFriend').dialog("open");
}
var showDialogFollow = function () {
    //if the contents have been hidden with css, you need this
    $('.divFollow').show();
    //open the dialog
    $('.divFollow').dialog("open");
}

//function to close dialog Friend and Follow, called by a button in the dialog
var closeDialogFriend = function () {
    $('.divFriend').dialog("close");
}

var closeDialogFollow = function () {
    $('.divFollow').dialog("close");
}

这是我的html片段:

<div class="divFollow"> 
        <asp:Table ID="TableFollow" runat="server">
            <asp:TableRow>
                <asp:TableCell HorizontalAlign="Right"> 
                    <input id="ButtonFollowClose" name="ButtonFollowClose" value="Close" type="button" />
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableCell>
                    <CMS:Invite ID="InviteControl" ClientIDMode="Static" runat="server" /> 
                </asp:TableCell>                   
            </asp:TableRow>               
        </asp:Table>                 
    </div>

    <div class="divFriend"> 
        <asp:Table ID="TableFriend" runat="server">
            <asp:TableRow>
                <asp:TableCell HorizontalAlign="Right"> 
                    <input id="ButtonFriendClose" name="buttonFriend" value="Close" type="button" />
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableCell>
                    <CMS:CommunitySearch ID="CommunitySearchID" ClientIDMode="Static" runat="server" />
                </asp:TableCell>                   
            </asp:TableRow>               
        </asp:Table>                 
    </div>

<div class="blogPost clearfix">
  <a class="FriendControl" href="#" >Friend</a>
  <a class="FollowControl" href="#" >Follow</a>
</div>

1 个答案:

答案 0 :(得分:0)

尝试修复JSLint突出显示的Javascript中的一些小错误。例如,每当你有:

var something = function() {
     // ...
}

确保你输入一个尾随的分号,因为你毕竟是在结束一个变量声明语句。即。

var something = function() {
     // ...
};

此外,更改$(document).ready()代码的最后两行,使})位于同一行,后跟分号。尝试自动插入分号时,Javascript可以做一些奇怪的事情,这可能会导致代码损坏。

即。它的格式应为:

$(document).ready(function () {
    // ...
});

尝试一下,看看你怎么走。另外,让我们知道这是什么浏览器 - 你在其他浏览器中测试过吗?