AJAX实现完整版

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>




日志


    

系统日志列表页面Ajax

time:<%=new java.util.Date() %>

id userName Method
数据加载中。。。
package com.jt.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.jt.common.vo.JsonResult;
import com.jt.common.vo.PageObject;
import com.jt.entity.SysLog;
import com.jt.service.SysLogService;

@RequestMapping("/log/")
@Controller
public class SysLogController {
    @Autowired
    private SysLogService SysLogService;
    
    @RequestMapping("doFindPageObjects")
    @ResponseBody
    public JsonResult doFindPageObjects(String username,Integer pageCurrent){
        return new JsonResult(SysLogService.findPageObjects(username,pageCurrent));
    }
    @RequestMapping("doFindPageLogs")
    public ModelAndView doFindPageLogs(String username,Integer pageCurrent){
        PageObjectpageObject= SysLogService.findPageObjects(username, pageCurrent);
        ModelAndView mv=new ModelAndView();
        mv.addObject("pageObject",pageObject);
        mv.setViewName("SysLog");
        return mv;
    }
    @RequestMapping("doLogListUI")
    public String doLogListUI(){
        try {
            Thread.sleep(5000);
        } catch (Exception e) {
        }
        return "SysLog-Ajax";
    }
}

xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
必须先open再setRequestHeader,如果这样调整
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xhr.open("POST", url, true);
会报如下错
InvalidStateError: XMLHttpRequest state must be OPENED.

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>




日志


    

系统日志列表页面Ajax

time:<%=new java.util.Date() %>

id userName Method
数据加载中。。。

你可能感兴趣的:(AJAX实现完整版)