我在一个jsp页面中有以下内容;

<script language="javascript">
    function ClickMe_Click(){
        $.ajax({
            type: "post",
            url: "dimensionList.jsp",
            data: "dimensionName=Slappy",
            success: function(msg) {
                alert(msg);
            }
            error: function(request,error){
                alert(error);
            }
        });
        return false;
    }
</script>
<a href="." onclick="return ClickMe_Click() ;">Click Me</a>


在我的DimensionList.jsp中;

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
    out.print("it works!");
%>


我遇到错误,但是当我警告错误时,我得到的错误却没有多大帮助。

最佳答案

function ClickMe_Click(){
    $.ajax({
        type: "post",
        url: "dimensionList.jsp",
        data: {"dimensionName":"Slappy"},
        success: function(msg) {
            alert(msg.data);
        },
        error:function (xhr, ajaxOptions, thrownError){
            alert(xhr.status);
            alert(thrownError);
        }
    });
    return false;
}


添加了以下指定的错误函数,以查看发生了什么,还修复了数据,您丢失了{}

10-07 19:07
查看更多