我继承了这个项目。我添加了最后12行代码。该错误与我添加的内容没有任何关系,但它会阻止开发工具停止在断点上。我的代码中的警报工作并给我正确的数据。但是,我没有在我认为我指向的复选框上获得“已检查”状态。很难调试。我得到“Uncaught TypeError:undefined不是函数”。它出现在脚本正下方>线。所以它似乎不是我的代码,但我找不到问题。我该如何调试此问题?
<script type="text/javascript">
colortab = function(tabName, color){
var tabs = ColdFusion.Layout.getTabLayout('mainTab');
var tab = tabs.getTab(tabName);
tab.el.dom.firstChild.firstChild.firstChild.style.color = color;
}
init = function(){
colortab('tab10', 'red');
}
</script>
<script type="text/javascript">
THIS IS WHERE THE ERROR SHOWS UP IN DEV TOOLS Uncaught TypeError: undefined is not a function
$(document).ready(function() {
//GetCityState = function(z){
//alert(z.value);
//$.ajax({
//type: 'Post',
//url: 'http://www.zip-info.com/cgi-local/zipsrch.exe',
//data: 'zip=' + z.value + '&Go=Go',
//success: function (response, textStatus, jqXHR) {
//alert('Response ' + response);
//},
//error: function(xhr, textStatus, errorThrown) {
// show error
//alert('error ' + errorThrown);
//}
//});
//}
$('#adminperson').click(function(){
ColdFusion.Window.show('AdminPersonWindow');
});
});
function SubmitAdminPersons() {
console.log("adminform " , $("#AdminPersonForm").serialize());
var AdminStr = $("#AdminPersonForm").serialize();
$.ajax({
type: 'Post',
url: 'cfc/updates.cfc?method=UpdateAdminPerson',
data: AdminStr,
success: function (response, textStatus, jqXHR) {
//alert('Response ' + response);
},
error: function(xhr, textStatus, errorThrown) {
// show error
alert('error ' + errorThrown);
}
});
ColdFusion.Window.hide('AdminPersonWindow');
alert('You have to refresh this page to see the new info.');
}
jQuery(document).ready(function() {
jQuery(".collapseContent").hide();
//toggle the componenet with class msg_body
jQuery(".collapseHeader").click(function()
{
jQuery(this).next(".collapseContent").slideToggle(500);
});
$('#jd_year').change(function() {
var jdyear = $('#jd_year').val();
//alert(jdyear);
if (jdyear){
$( "#skill_2" ).each(function( i ) {
if ( this.val() == "JD" ) {
this.checked;
return false;
}
});
}
});
});
</script>
答案 0 :(得分:0)
我认为此行“// show error”未在您的实际代码中注释。
请在以下代码中查看
$(document).ready(function(){
//GetCityState = function(z){
//alert(z.value);
//$.ajax({
//type: 'Post',
//url: 'http://www.zip-info.com/cgi-local/zipsrch.exe',
//data: 'zip=' + z.value + '&Go=Go',
//success: function (response, textStatus, jqXHR) {
//alert('Response ' + response);
//},
//error: function(xhr, textStatus, errorThrown) {
**// show error**
//alert('error ' + errorThrown);
//}
//});
//}