【发布时间】:2014-12-26 05:29:42
【问题描述】:
我尝试使用 javascript 调用一个模式,但是在运行该代码时我从控制台收到此错误:
Uncaught TypeError: undefined is not a function
我看过类似的问题,但没有一个对我有用。我的标题如下所示:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.7.0/underscore-min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
模态框将通过单击按钮使用 AJAX 填充。模态的 html 如下所示:
<div class="modal fade" id="edit" tabindex="-1" role="dialog" aria-labelledby="edit" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div id="slotedit"></div>
</div>
</div>
</div>
而 javascript 看起来像这样:
function getEdit(slotID) {
var xmlhttp = jQuery.noConflict();
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
//Change table element
document.getElementById("slotedit").innerHTML=xmlhttp.responseText;
$('#edit').modal('show');
}
}
xmlhttp.open("POST","getEditData.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("slotID=" + slotID);
}
有点难倒我,但是头部中js脚本的顺序似乎并没有改变任何东西,并且使用该方法在另一个模态上调用模态也不起作用(建议AJAX是可以的)。
谢谢
编辑:$('#edit')... 没有修复它:(
【问题讨论】:
标签: javascript jquery twitter-bootstrap bootstrap-modal