TypeError:e在控制台面板中为null [英] TypeError: e is null in console panel
本文介绍了TypeError:e在控制台面板中为null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好我在firebug控制台面板中收到此错误:TypeError:e为null
正如您将在我的代码中看到的那样,我想抓住那个错误但它不起作用,它显示上面的错误。
这是我的代码:
$。ajax({
type: POST,
url: Rooms.aspx / GetAvailRoom,
数据: ' {Checkin:' + $ checkinDate +
' ,Checkout:' + $ checkoutDate + ' }',
contentType: application / json; charset = utf-8,
dataType: json,
成功: function (响应){
var rooms = response.d;
alert(rooms);
var html = ' ';
if ($ .isEmptyObject(rooms)){
alert( 房间不可用!)
var $ showError = $(' #showError')。show()。text(' 很抱歉,您要求的日期没有空房。');
var $ showContact = $(' # showContact')。show()。html(' 如果您的日期灵活,请与酒店联系预订代理位于< strong> + 250788400000< / strong>。);
$(' #divRooms')。hide();
$(' #notificationError')。append($ showError,' < br />',$ showContact)
$(' div.loading')。hide();
}
else if ((rooms == ' undefined')&&(rooms == null ) ){
alert( 请返回并选择预订!);
}
其他 {
$ .each(rooms, function (index,item){
$ RoomId = item.RoomId;
html + = ' < ; div class =rowdata-id =' + item.RoomId + ' >';
html + = ' < div class =col-md-4> ';
html + = BxSlider(item);
html + = ' < / div>';
html + = ' < div class =col-md-4>';
html + = ' < ; h3 class =roomname success>' + item.RoomName + ' < / H3>'跨度>;
html + = ' < p class =price>< em> ' + item.RoomPrice + ' $< / em>每晚< / p>';
html + = ' < span class =amentiesHeader>完整说明< / span>'< /跨度>;
html + = ' < / div>';
html + = ' < div class =col-md-4>';
html + = ' < div class =roomextra>';
if (item.RoomDescription!= null ){
html + = ' < p class =notetitle>' + item.RoomDescription + ' < / p>';
}
html + = ' < button type =buttonclass =btn btn-success btn-block bookdata-id =' + $ RoomId + ' > ;现在预订< / button>';
html + = ' < / div>';
html + = ' < / div>';
html + = ' < / div>';
});
}
$(' #divRooms')。html (HTML);
$(' #divRooms div.row')。each( function (){
var RoomID = $( this )。attr( data-id);
var pagerid = ' #pager _' + RoomID;
$( this )。find(' ul.bxslider')。bxSlider({
pagerCustom:pagerid,
controls: false
});
});
$(' div.loading')。hide();
$(' 。book')。on( 点击, function (){
alert($ RoomId );
var url = 确认 - your-stay.aspx?checkin = + encodeURIComponent($ checkinDate)+ & checkout = +
encodeURIComponent($ checkoutDate)+ & roomId = + encodeURIComponent($ RoomId)+ & adults = + encodeURIComponent($ adults)
+ & children = + encodeURIComponent($ children);
窗口。 location .href = url;
});
$( #loading)。hide();
}
});
有人可以告诉我出了什么问题。
解决方案
< blockquote> .ajax({
type: POST,
url: Rooms.aspx / GetAvailRoom,
data:' {Checkin:' +
checkinDate +
' ,Checkout:' +
checkoutDate + ' }',
contentType: application / json; charset = utf-8,
dataType: json,
成功: function (响应){
var rooms = response.d;
alert(rooms);
var html = ' ';
if (
Hi I am getting this error in firebug console panel: TypeError: e is null
As you will see in my code bellow, I ma trying to catch that error but it is not working, it is displaying that error above.
This is my code:
$.ajax({
type: "POST",
url: "Rooms.aspx/GetAvailRoom",
data: '{ Checkin: "' + $checkinDate +
'", Checkout: "' + $checkoutDate + '" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
var rooms = response.d;
alert(rooms);
var html = '';
if ($.isEmptyObject(rooms)) {
alert("Room is not Available!")
var $showError = $('#showError').show().text('We are sorry, there are no rooms available for the dates you have requested.');
var $showContact = $('#showContact').show().html('If your dates are flexible, please speak to a hotel reservation agent at <strong>+250788400000</strong>.');
$('#divRooms').hide();
$('#notificationError').append($showError, '<br/>', $showContact)
$('div.loading').hide();
}
else if ((rooms == 'undefined') && (rooms == null)) {
alert("Please go back and choose reservation!");
}
else {
$.each(rooms, function (index, item) {
$RoomId = item.RoomId;
html += '<div class="row" data-id=' + item.RoomId + '>';
html += '<div class="col-md-4">';
html += BxSlider(item);
html += '</div>';
html += '<div class="col-md-4">';
html += '<h3 class="roomname success">' + item.RoomName + '</h3>';
html += '<p class="price"><em> ' + item.RoomPrice + '$</em> per night</p>';
html += '<span class="amentiesHeader">Full Description</span>';
html += '</div>';
html += '<div class="col-md-4">';
html += '<div class="roomextra">';
if (item.RoomDescription != null) {
html += '<p class="notetitle">' + item.RoomDescription + '</p>';
}
html += '<button type="button" class="btn btn-success btn-block book" data-id=' + $RoomId + '>BOOK NOW</button>';
html += '</div>';
html += '</div>';
html += '</div>';
});
}
$('#divRooms').html(html);
$('#divRooms div.row').each(function () {
var RoomID = $(this).attr("data-id");
var pagerid = '#pager_' + RoomID;
$(this).find('ul.bxslider').bxSlider({
pagerCustom: pagerid,
controls: false
});
});
$('div.loading').hide();
$('.book').on("click", function () {
alert($RoomId);
var url = "confirm-your-stay.aspx?checkin=" + encodeURIComponent($checkinDate) + "&checkout=" +
encodeURIComponent($checkoutDate) + "&roomId=" + encodeURIComponent($RoomId) + "&adults=" + encodeURIComponent($adults)
+ "&children=" + encodeURIComponent($children);
window.location.href = url;
});
$("#loading").hide();
}
});
Can someone tell me what is wrong.
解决方案
.ajax({ type: "POST", url: "Rooms.aspx/GetAvailRoom", data: '{ Checkin: "' +
checkinDate + '", Checkout: "' +
checkoutDate + '" }', contentType: "application/json; charset=utf-8", dataType: "json", success: function (response) { var rooms = response.d; alert(rooms); var html = ''; if (
这篇关于TypeError:e在控制台面板中为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文