ajaxpro未定义的问题

本地测试成功的代码传到虚拟空间出现这样的错误
方法一、
首先打开IIS配置--》主目录--》选择配置(权限配置)--》这里则有扩展的权限配置,添加浏览       c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll
扩展名为     .ashx  
动作:限制为     GET,HEAD,POST,DEBUG
添加
<httpHandlers>
         
<add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro.2"/>
</httpHandlers>
方法二、'AjaxPro'未定义错误的原因&javascript顺序执行&AjaxPro机制
 首先我们说说AjaxPro.Utility.RegisterTypeForAjax到底做了什么?
Ajax的基本原理其实很简单,就是XmlHttpRequest通道加异步。AjaxPro起到就是框架和包装器的作用,一般我们在on_load里面用AjaxPro.Utility.RegisterTypeForAjax实现这些(当然这里面AjaxPro.AjaxMethod()起到配合的作用),到底做了什么呢?服务端就不说了(我估计用到了缓存方法),在客户端aspx(html)页面里紧跟<form name="form1" method="post" action="Default3.aspx" id="form1">隔着VIEWSTATE生成了下面注册脚本
<script type="text/javascript" src="/Web/ajaxpro/prototype.ashx"></script>
<script type="text/javascript" src="/Web/ajaxpro/core.ashx"></script>
<script type="text/javascript" src="/Web/ajaxpro/converter.ashx"></script>
<script type="text/javascript" src="/Web/ajaxpro/Default3,App_Web_wvuzlcxq.ashx"></script>

上面这些javascript就是AjaxPro实现了Ajax框架和通道的包,其中<script type="text/javascript" src="/Web/ajaxpro/core.ashx"></script>里面有AjaxPro.onLoading的声明!
        下面该说出现'AjaxPro'未定义错误的原因了!
在我这里出现这种错误的情况是这样的
Default3.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
     <title>无标题页</title>
     <script type="text/javascript">
function get(r)
{
document.getElementById("m").innerText=(r.value);
}
AjaxPro.onLoading=function(b){
document.getElementById("loading").style.display = b ? "block" : "none";
}
</script>
</head>
<body>
     <form id="form1" runat="server">
     <div>
     <div id="loading" style="display:none;">正在获取服务器端时间
         </div>
             <div id="m" style="display:block;">
         </div>  
         <input id="but" type="button" value="button"  />

     </div>
     </form>
</body>
</html>
Default3.aspx.cs
。。。
public partial class Default3 : System.Web.UI.Page
{
     protected void Page_Load(object sender, EventArgs e)
     {
         AjaxPro.Utility.RegisterTypeForAjax(typeof(Default3));
     }
     [AjaxPro.AjaxMethod]
     //[AjaxPro.AjaxServerCache(10)]
     public string   gett()
     {
         System.Threading.Thread.Sleep(2000);
         return DateTime.Now.ToString();
     }
}
你可以看到我把AjaxPro.onLoading放到了<form id="form1" runat="server">上面,也就是说源文件里放到了
<script type="text/javascript" src="/Web/ajaxpro/prototype.ashx"></script>
<script type="text/javascript" src="/Web/ajaxpro/core.ashx"></script>
<script type="text/javascript" src="/Web/ajaxpro/converter.ashx"></script>
<script type="text/javascript" src="/Web/ajaxpro/Default3,App_Web_wvuzlcxq.ashx"></script>
的上面,由于javascript是顺序执行的,所以就出现了'AjaxPro'未定义错误!
我把html文件改成下面
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
     <title>无标题页</title>
</head>
<body>
     <form id="form1" runat="server">
<script type="text/javascript">
function get(r)
{
document.getElementById("m").innerText=(r.value);
}
AjaxPro.onLoading=function(b){
document.getElementById("loading").style.display = b ? "block" : "none";
}
</script >
     <div>
     <div id="loading" style="display:none;">正在获取服务器端时间
         </div>
             <div id="m" style="display:block;">
         </div>  
         <input id="but" type="button" value="button"  />

     </div>
     </form>
</body>
</html>

转载于:https://www.cnblogs.com/webmake/archive/2009/01/01/1366623.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值