绿豆.Net

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::

infopath 结合ajax扩充提交功能

// 提交 infopath里自带的提交用起来有限制,很多规则和代码不能在提交前后自动执行,如果用代码实现提交功能,那么可以做好多事情。不过只限于提交方式为"Web服务器 Http"
function postForm()
{
   try
   {
      var objXmlHttp = new ActiveXObject("MSXML2.XMLHTTP");
   }
   catch(ex)
   {
      XDocument.UI.Alert("Could not create MSXML2.XMLHTTP object.\r\n" + ex.number + " - " + ex.description);
      return false; 
   }
  
   //var strUrl = "http://www.sunfunsoft.com/XXXXX1/submit.aspx";
   var strUrl = "http://www.sunfunsoft.com/XXXXX2/submit.aspx";
  
   // Post the XML document to strUrl.
   objXmlHttp.open("POST", strUrl, false);
   try
   {
      objXmlHttp.send(XDocument.DOM.xml);
   }
   catch(ex)
   {
      XDocument.UI.Alert("Could not post (ASP) document to " + strUrl + "\r\n" + ex.number + " - " + ex.description);
      return false;
   }
   if(objXmlHttp.status == 200)
   {
  
  
  if(objXmlHttp.responseText.indexOf("成功") >= 0 || objXmlHttp.responseText == "")
  {
      XDocument.UI.Alert("提交成功!");
      return true;
  }
  else
  {
      XDocument.UI.Alert(objXmlHttp.responseText);
      return false;
  }
   }
   else
   {
       
        XDocument.UI.Alert("由于网络或其它原因,表单没有提交成功!");
        return false;
   }
}
posted on 2008-03-03 14:12  杜军  阅读(387)  评论(0)    收藏  举报