加载(URL,参数)不是一个函数?

时间:2019-02-02 16:59:54

标签: javascript java jquery jsp

我如何使用jQuery POST或GET将此字符串模式参数(经过硬编码的atm)传递给模态。目的是用它替换我网页上的某些div。调用时,传递的参数使模式面板的行为动态化,使其适应我传递给它的任何模式和参数。

但是,我似乎无法发送参数。另外,我以后如何在模态中获取这些参数?

这是我的“测试索引页”:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/include.jsp"%>
<%@ taglib prefix="t" tagdir="/WEB-INF/tags"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<t:base>
    <h1>Welcome to Absence</h1>
    <div id="testingDiv" class="container-fluid">
        <h2>Testeo</h2>
        <div id="contactProvider">
            <button id="openContactModal" type="button" class="btn btn-primary" onclick="openContactModal()">Primary</button>
            <div class="divContactModal"></div>
        </div>
    </div>
</t:base>


<script type="text/javascript">
    function openContactModal() {
        var mode = "contactar"; 

        var url = "Contact/contactProviderModal.jsp"; 

        $("#divContactModal").load(url, mode);
    };
</script>

这是必须得到的参数并重新格式化自己的情况设定的模式:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/include.jsp"%>
<%@ taglib prefix="t" tagdir="/WEB-INF/tags"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<t:base>
    <div id="contactModal" class="modal fade" tabindex="-1" role="dialog">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">
                        <!--Title set with jQuery.js script-->
                    </h5>
                </div>
                <div class="modal-body">
                    <!--Body set with jQuery.js script-->
                </div>
                <div class="modal-footer">
                    <!--Footer set with JSTL ("inline script")-->
                    <c:choose>
                        <c:when test="">
                            test="${mode == 'contactar'}">
                            <button type="button" class="btn btn-primary">Contactar Proveedor</button>
                        </c:when>
                        <c:when test="">
                            test="${mode == 'cancelar'}">
                            <button type="button" class="btn btn-danger">Cancelar Contacto</button>
                        </c:when>
                    </c:choose>
                </div>
            </div>
        </div>
    </div>
</t:base>

<!-- jQuery.js function executed when modal is loaded, configuring its content dynamically-->
<script type="text/javascript">
    var mode = "${mode}";
    if (mode == "contactar") {
        $("#modal-title").text("Contactar Proveedor");
        $("#modal-body").text("TODO"            
        ); 
        $("#contactModal").show();
    } else {
        $("#modal-title").text("Cancelar Contacto");
        $("#modal-body").text("Estas seguro de que deseas cancelar tu solicitud?");
        $("#contactModal").show();
    }
</script>

编辑:还尝试了$("#divContactModal").load(url+"?mode="+mode);,但没有结果: this is the error i get EDIT2:@charlietfl解决了该错误,但未显示模式。

0 个答案:

没有答案