Jquery异步提交,回调函数无法触发

[code="java"]
<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">



主界面






<br> &lt;%@ include file=&quot;tree.js&quot;%&gt;<br> &lt;%@ include file=&quot;datagrid.js&quot;%&gt;</p> <pre><code>$(document).ready(function(){ $(&quot;#selectButton&quot;).click(function(){ clickButton(); }); }); function clickButton() { var url = &#39;select.do&#39;; var params = { beginTime:$(&#39;#beginTime&#39;).attr(&#39;value&#39;), endTime:$(&#39;#endTime&#39;).attr(&#39;value&#39;)//对应的是控件的Id,之前错写成了Name,一个小小的错误也是毁灭性的打击 }; jQuery.post(url,params,callbackFun,&#39;json&#39;); } function callbackFun(data)//我看网上也可以写与Result,应该是任意的,是一个Json值 { alert(&quot;SUCCESS&quot;); } </code></pre> <p>




开始时间
结束时间


    <div region="south" title="South Title" split="true" style="height:100px;padding:10px;background:#efefef;">
        <div class="easyui-layout" fit="true" style="background:#ccc;">
            <div region="center">sub center</div>
            <div region="east" split="true" style="width:200px;">sub center</div>
        </div>
    </div>
    <div region="west" iconCls="icon-reload" title="部门树形结构" split="true" style="width:230px;">
        <ul id="depttree"></ul>
    </div>      
    <div region="center" title="Main Title" style="overflow:hidden;">
        <div class="easyui-tabs" fit="true" border="false" >
            <div title="Tab1">
            <table id="datagrid" region="center"></table>                   
            </div>
            <div title="Tab2" closable="true" style="padding:20px;">This is Tab2 width close button.</div>
            <div title="Tab3" iconCls="icon-reload" closable="true" style="overflow:hidden;padding:5px;">
            </div>
        </div>
    </div>

[/code]

[code="java"]package com.zheshou.action;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.InterceptorRef;
import org.apache.struts2.convention.annotation.InterceptorRefs;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.apache.struts2.interceptor.validation.SkipValidation;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.web.portlet.bind.annotation.ResourceMapping;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.validator.annotations.*;
import com.sun.jndi.url.corbaname.corbanameURLContextFactory;
import com.zheshou.model.Employee;
import com.zheshou.model.User;
import com.zheshou.service.EmployeeService;

@ParentPackage(value="json-default")
@Namespace(value="/")

public class SelectAction extends ActionSupport {//2.ActionSupport必须有这个才行.但是可以不用Execute了
private String beginTime;

private String endTime; 

private com.zheshou.model.User user;

public com.zheshou.model.User getUser() {
    return user;
}

public void setUser(com.zheshou.model.User user) {
    this.user = user;
}   

public String getBeginTime() {
    return beginTime;
}

public void setBeginTime(String beginTime) {
    this.beginTime = beginTime;
}

public String getEndTime() {
    return endTime;
}

public void setEndTime(String endTime) {
    this.endTime = endTime;
}

@Action(value="select"
    ,results={@Result(
            type="json"
            ,name="selectuser"
            ,params={"includeProperties","user.*"}//root
                )}
           )               
public String execute(){
    System.out.println(beginTime);
    System.out.println(endTime);
    user.setId(1);
    user.setUsername("张三");
    return "selectuser";
}

}
[/code]

核心代码,如上,不知道为什么,回归函数,就是触发不了,其它的,都正常

2个回答

回调没有执行,
看看是不是你的action代码不正确,后台报错了没有,使用firebug调试下

你的前端代码本身没有问题,请检查,后端的输出是否正确,必须是 JSON 代码。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问