使用JSON插件 jquery

<%--
网站: <a href="http://www.crazyit.org">疯狂Java联盟</a>
author  yeeku.H.lee kongyeeku@163.com
version  1.0
Copyright (C), 2001-2012, yeeku.H.Lee
This program is protected by copyright laws.
Program Name:
Date:
--%>

<%@ page contentType="text/html; charset=GBK" language="java" errorPage="" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!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>
    <title>使用JSON插件</title>
    <script src="${pageContext.request.contextPath}/jquery-1.4.4.min.js"
    type="text/javascript">
    </script>
</head>
<body>
<s:form id="loginForm">
    <s:textfield name="user" label="用户名"/>
    <s:textfield name="pass" label="密码"/>
    <tr>
        <td colspan="2">
            <input id="loginBn" type="button" value="提交"/>
        </td>
    </tr>
</s:form>
<div id="show" style="display:none;">
</div>
<script type="text/javascript">
    //为id为loginBn的按钮绑定事件处理函数
    $("#loginBn").click(function(){
        //指定向loginPro发送请求,以id为loginForm表单里各表单控件作为请求参数
        $.get("loginPro" ,$("#loginForm").serializeArray(),
            //指定回调函数
            function(data , statusText)
            {
                $("#show").height(80).width(300)
                    .css("border" , "1px solid black")
                    .css("background-color" , "#efef99")
                    .css("color" , "#ff0000")
                    .css("padding" , "20px")
                    .empty();
                $("#show").append("登录结果:" + data + "<br />");
                $("#show").show(2000);
            },
            //指定服务器响应为html
            "html");
    });
</script>
</body>
</html>


<action name="loginPro" class="org.crazyit.app.action.LoginAction">
    <result name="success" type="stream">
        <!-- 指定下载文件的文件类型 -->
        <param name="contentType">text/html</param>
        <!-- 指定由getResult()方法返回输出结果的InputStream -->
        <param name="inputName">result</param>
    </result>
    <!-- 定义一个名为login的结果 -->
     <result name="login">/WEB-INF/content/login.jsp</result>
</action>


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值