Ajax+jsp铺个界面

<%@page import="com.sun.tools.internal.xjc.model.Model"%>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<% int i = 10 ;%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link rel="stylesheet" href="${ctx}/content/css/reset.css" />
    <link rel="stylesheet" href="${ctx }/content/css/right.css" />
    <link rel="stylesheet" href="${ctx }/content/css/info.css" />
    <script type="text/javascript" src="${ctx }/content/js/jquery-1.7.1.min.js"></script>

    <script type="text/javascript" src="${ctx }/content/layer/layer.js"></script>
    <style type="text/css">
        .image div{width:22%; float: left;margin-right:5px;}
        .image div img{width: 100%;height: 100%;}
        html, body{margin:0;padding-top:0px;padding-bottom:0px; height:100%;}
        .tag-editor{border: 1px solid #ccc;width: 93%;}
        .exp1{font-size:18px; text-align:center} 
    </style>
</head>
<body>
    <input type="hidden" id="giGtId" value=""/>
    <br/>
    <h1 class="exp1"  >新闻录入界面<%=i %></h1>
    <table class="shaixuan">
        <tr height="36">
            <td width=" 10%" class="TD3">文章标题:</td>
            <td width="65%" class="TD2"><input id="newsTitle" maxlength="15" class="shuru" style="width:80%;" type="text"/></td>
        </tr>
        <tr height="36">
            <td width=" 10%" class="TD3">文章副标题:</td>
            <td class="TD2"><input id="newsSubTitle" maxlength="15" class="shuru" style="width:80%;" type="text"/></td>
        </tr>
        <tr height="36">
            <td width=" 10 %" class="TD3" >文章内容:</td><td/>
        </tr>
        <tr  height="340" align="center">   
        <td  class="TD2" height="340"  colspan="2" style="text-align:center"  >
        <textarea  id="newsContent"  style="width:70%;height:100%"    ></textarea>
        </td>
        </tr>
        <tr height="36">
            <td width="10%" class="TD3">文章状态:</td><td class="TD2">
            <input id="newsState" maxlength="15" class="shuru" style="width:80%;" type="text"/></td>
        </tr>
        <tr height="36">
            <td width="10%" class="TD3">文章类型:</td><td class="TD2">
            <input id="newsType" maxlength="15" class="shuru" style="width:80%;" type="text"/></td>
        </tr>
        <tr height="36">
            <td width="10%" class="TD3">文章封页:</td><td class="TD2">
            <input id="newsImg" maxlength="15" class="shuru" style="width:80%;" type="text"/></td>
        </tr>
        <tr height="36">
            <td colspan="4"  style="margin-left:50%;" class="TD3">
                <div class="caozuo" style="margin-left:44%;">
                    <a href="javascript:save()" style="width:80px; text-align:center;  height:30px; line-height:30px;">保存</a>
                </div>
            </td>
        </tr>
    </table>


</body>
<script type="text/javascript">


    function save(){

        if($.trim($("#newsTitle").val())== ""||$.trim($("#newsSubTitle").val())== ""||
                $.trim($("#newsContent").val())== ""||$.trim($("#newsState").val())== ""||
                $.trim($("#newsType").val())== ""||$.trim($("#newsImg").val())== ""){

            layer.msg("输入不能为空");
            return;
        }
        var load = layer.load(1);
        $.ajax({
            url : '${ctx}/api/news/addNews.do',
            type : 'post',
            timeout : 8000,
            data : {'newsTitle':$("#newsTitle").val(),
                    'newsSubTitle':$("#newsSubTitle").val(),
                    'newsContent':$("#newsContent").val(),
                    'newsState':$("#newsState").val(),
                    'newsType':$("#newsType").val(),
                    'newsImg':$("#newsImg").val()},
            dataType : 'json',
            success : function(result){
                layer.msg("成功");
                layer.close(load);
                layer.msg(result.msg);
            },
            error: function(){
                layer.msg("错误");
                layer.close(load);

            }
        }) 
    }


</script>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值