Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/368.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 无法从ajax调用获取数据以显示通知_Javascript_Jquery_Ajax - Fatal编程技术网

Javascript 无法从ajax调用获取数据以显示通知

Javascript 无法从ajax调用获取数据以显示通知,javascript,jquery,ajax,Javascript,Jquery,Ajax,使用2个ajax调用在布局中显示通知。第一个ajax调用数据出现并显示通知,但seconc函数未获取数据且未显示任何通知 代码 $(文档).ready(函数(){ LoadNotification(); LoadTankNotification(); setInterval(函数(){ LoadNotification(); LoadTankNotification(); }, 30000); 函数LoadNotification(){ $.ajax({ url:'@url.Action(“G

使用2个ajax调用在布局中显示通知。第一个ajax调用数据出现并显示通知,但seconc函数未获取数据且未显示任何通知

代码


$(文档).ready(函数(){
LoadNotification();
LoadTankNotification();
setInterval(函数(){
LoadNotification();
LoadTankNotification();
}, 30000);
函数LoadNotification(){
$.ajax({
url:'@url.Action(“GetBinNotification”、“smartbin”)',
键入:“POST”,
成功:功能(数据){
if(data.success){
$(.binnotification.binlabel”).text(data.model.length);
$(“.binnotification.dropdown menu>li.header”).text('您有'+data.model.length+'个箱子被填满');
var htmlofNotification='';
$(data.model)。每个(函数(i,项){
item.Filled=item.Filled.toFixed(2);
htmlofNotification+='
  • '+ '' + “
  • ”; }); $('.binnotification.dropdown menu ul.menu').html(htmlofNotification); } } }); } //水缸维修通知书 函数LoadTankNotification(){ $.ajax({ url:'@url.Action(“GetWaterNotification”,“水位”), 键入:“POST”, 成功:功能(数据){ if(data.success){ $(“.tanknotification.tanklabel”).text(data.model.length); $(“.tanknotification.dropdown menu>li.header”).text('您有'+data.model.length+'个箱子被填满'); var htmlofNotification1=''; $(data.model)。每个(函数(i,项){ item.Filled=item.Filled.toFixed(2); htmlofNotification1+='
  • '+ '' + “
  • ”; }); $('.tanknotification.dropdown menu ul.menu').html(htmlofNotification1); } } }); } });

    浏览器控制台中有错误吗?第二个ajax请求的状态是什么?服务器返回什么结果(无论是错误还是数据)?第二个方法给出错误-xhr.send((options.hasContent&&options.data)| null)//未能加载资源:服务器以404(未找到)的状态响应。我已获得错误并已解决。下次我的朋友,如果你想对我的评论发表评论,请提到我(@niceman):)顺便说一句,回答你的问题,这样我们就知道你的问题已经解决了
    <script>
            $(document).ready(function () {
                LoadNotification();
                LoadTankNotification();
                setInterval(function () {
                    LoadNotification();
                    LoadTankNotification();
                }, 30000);
    
                function LoadNotification() {
                    $.ajax({
                        url: '@Url.Action("GetBinNotification", "smartbin")',
                        type: 'POST',
                        success: function (data) {
                            if (data.success) {
                                $(".binnotification .binlabel").text(data.model.length);
                                $(".binnotification .dropdown-menu > li.header").text('you have ' + data.model.length + ' bins are filled');
                                var htmlofNotification = '';
                                $(data.model).each(function (i, item) {
                                    item.Filled = item.Filled.toFixed(2);
                                    htmlofNotification += '<li>' +
                                        '<a href="#">' +
                                            '<h3>' + item.BinName + '<small class="pull-right">' + item.Filled + '%</small>' + '</h3>' +
                                            '<div class="progress xs">' +
                                                '<div class="progress-bar progress-bar-aqua" style="width: ' + item.Filled + '%" role="progressbar" aria-valuenow="' + item.Filled + '" aria-valuemin="0" aria-valuemax="100">' +
                                                    '<span class="sr-only">' + item.Filled + '% Complete</span>' +
                                                '</div>' +
                                            '</div>' +
                                        '</a>' +
                                    '</li>';
                                });
                                $('.binnotification .dropdown-menu ul.menu').html(htmlofNotification);
    
                            }
                        }
                    });
                }
                //notification for water tank kadma
                function LoadTankNotification() {
                    $.ajax({
                        url: '@Url.Action("GetWaterNotification", "WaterLevel")',
                        type: 'POST',
                        success: function (data) {
                            if (data.success) {
                                $(".tanknotification .tanklabel").text(data.model.length);
                                $(".tanknotification .dropdown-menu > li.header").text('you have ' + data.model.length + ' bins are filled');
                                var htmlofNotification1 = '';
                                $(data.model).each(function (i, item) {
                                    item.Filled = item.Filled.toFixed(2);
                                    htmlofNotification1 += '<li>' +
                                        '<a href="#">' +
                                            '<h3>' + item.watertankName + '<small class="pull-right">' + item.Filled + '%</small>' + '</h3>' +
                                            '<div class="progress xs">' +
                                                '<div class="progress-bar progress-bar-aqua" style="width: ' + item.Filled + '%" role="progressbar" aria-valuenow="' + item.Filled + '" aria-valuemin="0" aria-valuemax="100">' +
                                                    '<span class="sr-only">' + item.Filled + '% Complete</span>' +
                                                '</div>' +
                                            '</div>' +
                                        '</a>' +
                                    '</li>';
                                });
                                $('.tanknotification .dropdown-menu ul.menu').html(htmlofNotification1);
    
                            }
                        }
                    });
                }
    
            });
    
    
        </script>