日期:2014-05-16  浏览次数:20846 次

急救!!!菜鸟学习jquery ajax 求一实例 要完整的 谢谢 - Web 开发 / Ajax
本人刚刚学习jQuery,想在登陆的时候用一用。因为比较笨,在看了很多资料还是不知道怎么弄,没有办法了。求高手帮个小忙。能不能给一个例子,包括怎么请求,提交后如何处理(如果成功信息要放到session里),如何返回一个Boolean值。谢谢了。我用的是asp.net(不知道这句是不是废话,呵呵)。

------解决方案--------------------
http://blog.csdn.net/fcsh820/archive/2009/02/02/3857947.aspx
------解决方案--------------------
页面:<input type='text' id='name'> <input type='text' id='password'>
<button id='login'>提交登陆</button>
----------------------------
js:
$(function(){
$("login").click(function(){
var name='$("#name")';
var name='$("#password")'
$.getJSON('login.do'//路径,{name:name,password:password}//传送的参数,function (json){
//回调函数
if(json==0){
alert("用户不存在");
}else{
alert("用户已存在");
}
})
})

})
----------------------------
servlet: String name=request.getParament("name");
String password=request.getParament("password");
判断用户是否存在
jsonArray array=new JsonArray();
if(user==null){
array.addAll("0");
}else{
array.addAll("1");
}
------解决方案--------------------
JScript code


<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <base href="<%=basePath%>">

        <title>My JSP 'newfive.jsp' starting page</title>

        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">
        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="This is my page">
        <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
        <style type="text/css">
        .red{
            background-color: red;
            color:yellow;
        }
        .green{
            background-color: green;
            color:white;
        }
    </style>

        <script type="text/javascript" src="js/jquery.js"></script>
        <script type="text/javascript">
        $().ready(function(){
            $('#mydiv').addClass("green");
            $('#b1').click(function(){
                $('#mydiv').fadeTo("slow",1);//淡入
            });
            $('#b2').click(function(){
                $('#mydiv').fadeTo("slow",0);//淡出
            });
        
            $('#b3').click(function(){
                $('#mydiv').hide("slow");//隐藏
            });
            $('#b4').click(function(){
                $('#mydiv').show("slow");//展示(隐藏后才有用)
            });
            
            $('#b5').click(function(){
                $('#mydiv').slideUp("slow");//向上合拢
            });
            $('#b6').click(function(){
                $('#mydiv').slideDown("slow");//向下展开
            });
            
            $('#b7').click(function(){
                $('#mydiv').toggle(&qu