我用ajax调用webservcie,在网络不通的时候会自动弹出错误对话框,我不想它弹出错误的对话框请问有什么办法
我的代码如下:
try
{
    OAWeb.Service.IsHaveMyChatContent("<%=Session["UserID"].ToString()>",IsHaveMyChatContentresult_fun);
}
catch(e)
{
}现在我想用try来忽略这个异常,但不成功,它还是会弹出连接出错的对话框,因为我这个方法是几十秒就定时调用的,所以经常会弹出出错的对话框,不知道有什么办法可以解决?

解决方案 »

  1.   

    参考下 ··
    http://aspxboy.com/private/5156/default.aspx
      

  2.   

    试试
    try
    {
        OAWeb.Service.IsHaveMyChatContent(" <%=Session["UserID"].ToString()>",IsHaveMyChatContentresult_fun);
    }
    catch
    {

    把你的代码贴全看看/
      

  3.   

    参考 
    [WebServiceBinding(ConformanceClaims=WsiClaims.BP10,EmitConformanceClaims = true)]
    public class Service : System.Web.Services.WebService 
    {
    XmlQualifiedName xname;
    [WebMethod]
    public int causeexception(int num)
    {
    int n; 
    软件开发网 www.mscto.comtry
    {
    n=num;
    if (n == 1)
    {
    throw new e1("erroe e1 happen");
    }
    if (n == 2)
    {
    throw new e2("erroe e2 happen");
    }
    }
    catch(ApplicationException ex)
    {
    throw GetException(ex);
    }return n;}
    private SoapException GetException(ApplicationException exx)
    {if (exx is e1)
    {
    xname = new XmlQualifiedName("e1");
    }
    if (exx is e2)
    {
    xname = new XmlQualifiedName("e2");
    }
    return new SoapException(exx.Message, xname);
    }}客户端:
    private void button1_Click(object sender, EventArgs e)
    {
    try
    {
    exception.Service s = new testexception.exception.Service();//实例化代理
    if (this.radioButton1.Checked)
    {
    s.causeexception(1);//引发异常
    }
    if (this.radioButton2.Checked)
    {
    s.causeexception(2);
    }

    catch (SoapException ex)
    {
    switch(ex.Code.ToString())//根据SOAPEXCEPTION.CODE的值显示相应的消息
    {
    case "e1":MessageBox.Show("has error e1");
    break;
    case "e2":MessageBox.Show("has error e2");
    break;
    }
    }}
      

  4.   

    我要的是javascript代码 <script language="javascript" type="text/javascript">
        function Window_Load()
        {
        window.setTimeout("HeartJump()",20000);
        window.setTimeout("GetMyChatMsg()",10000);
        }
        function HeartJump() //心脏跳动
        {
            try
            {
            OAWeb.Service.HeartJump("<%=Session["UserID"].ToString()%>","<%=Session["UserName"].ToString()%>");
        }
        catch(e)
        {}
        window.setTimeout("HeartJump()",20000); //20秒跳动一次
        }
        function GetMyChatMsg()
        {
            try
            {
                OAWeb.Service.IsHaveMyChatContent("<%=Session["UserID"].ToString()%>",IsHaveMyChatContentresult_fun);
            }
            catch(e)
            {
            }
        window.setTimeout("GetMyChatMsg()",10000);
        }
        //接收WebService函数的返回值
            function IsHaveMyChatContentresult_fun(result){
    if(result=="1")
        window.open('ChatMain.aspx','ChatMain<%=Session["UserID"].ToString() %>','toolbar=no,location=no,status=no,menubar=no,resizable=yes,width=800,height=600');
            }
            function IEWindow_Close()
            {
            if(window.event.clientX<0)
             OAWeb.Service.DeleteUser("<%=Session["UserID"].ToString()%>");
            }
    </script> 这是我的全部代码
    to xray2005
    去掉(e) 是不行的