zoukankan      html  css  js  c++  java
  • 温故AjaxPro系列之二

          上一篇文章讲到的例子“输出Hello AjaxPro!".其实客户端调用的js中,_Default.Hello(),可以再添加一个可选的参数。这个参数的异步请求后的CallBack函数。CallBack函数中的有一个参数,它接收了response对象。参数的主要属性如下:

    value

    服务器端返回的真实值

    error

    任何错误信息

    request

    xml http request 的原始请求对象.

    context

    上下文对象

           修改后的Default.aspx代码如下:

    代码
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AjaxProDemo._Default" %>

    <!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 GetHello()
         {
             
    var Ret = _Default.Hello(CallBack);
             
    //alert(Ret.value);
             return;
         }
         
         
    function CallBack(response)
         {
            
    if(response.error != null)
            {
                alert(response.error);
                
    return;
            }
            alert(response.value);
         }
        
    </script>
    </head>
    <body>
        
    <form id="form1" runat="server">
            
    <input id="Hl_Bth1" type="button" value="Hello"  onclick="GetHello();"/>
            
        
    </form>
         
    </body>
    </html>

    运行后,结果跟上次的一样。

  • 相关阅读:
    Day1-while and for/break and continue
    Day1-用户输入及字符串格式化输入
    Day1-python基础
    2-21-源码编译搭建LNMP环境
    2-20-使用apache搭建web网站
    2-19-mysql优化
    2-18-搭建mysql集群实现高可用
    2-17-MySQL读写分离-mysql-proxy
    2-16-2MySQL主从
    2-14-存储过程-触发器-事务
  • 原文地址:https://www.cnblogs.com/luoguoqiang1985/p/1674752.html
Copyright © 2011-2022 走看看