jquery ajax循环只返回最后一个值(jquery ajax loop only returning last value)
我有几个不同服务的ajax调用。 我知道每次连续调用都会覆盖我的数组
var log
,但我无法弄清楚如何更改逻辑以附加下一个数组而不是覆盖。$.ajax($.extend({}, ajaxDefaults, source, { data: data, success: function(events) { events = events || []; var res = applyAll(success, this, arguments); if ($.isArray(res)) { events = res; } callback(events); var log = log || []; for (var i=0; i<events.length; i++) { log.push(events[i]); } console.log(log); }, error: function() { applyAll(error, this, arguments); callback(); }, complete: function(events) { applyAll(complete, this, arguments); popLoading(); } }));
I have an ajax call to several different services. I know my array
var log
is being overwritten by each successive call, but I can't figure out how to change the logic to append the next array instead of overwriting.$.ajax($.extend({}, ajaxDefaults, source, { data: data, success: function(events) { events = events || []; var res = applyAll(success, this, arguments); if ($.isArray(res)) { events = res; } callback(events); var log = log || []; for (var i=0; i<events.length; i++) { log.push(events[i]); } console.log(log); }, error: function() { applyAll(error, this, arguments); callback(); }, complete: function(events) { applyAll(complete, this, arguments); popLoading(); } }));
原文:https://stackoverflow.com/questions/29908972
更新时间:2024-05-04 16:05
最满意答案
我最近有同样的问题。 但是有一点延迟(超时)为我解决了这个问题:
jQuery(document).ready(function($){ window.setTimeout(function(){ $('input.datepicker').Zebra_DatePicker(); }, 100); });
I recently have the same problem. But a little delay (timeout) solves the issue for me:
jQuery(document).ready(function($){ window.setTimeout(function(){ $('input.datepicker').Zebra_DatePicker(); }, 100); });
相关问答
更多-
我不确定Zebra_DatePicker,它是否给出了周数,但即使它没有直接给你一周的数字,如果你有日期和月份,你可以自己解决...例如这种方式 week = math.ceil((month * day)/7); 这将为您提供一年中的一周。 另一方面,如果你甚至无法得到日期和月份,那么通过分割日期来获得它。 var now = new Date(document.getElementById('element_id').value);//replace the element_id with actua ...
-
您需要使用focus而不是click 。 使用点击意味着您必须在输入字段中单击,然后激活,因此您必须单击该字段并返回其中才能使其生效。 你还有$(this).datepick而不是$(this).datepicker 。 $("body").on("focus", ".datepick", function () { $(this).datepicker({ dateFormat: "yyyy-mm-dd", rangeSelect: true }); }); ...
-
第一次加载时,斑马日期选择器位置不计算(zebra datepicker position is not calculating while loading first time)[2022-03-30]
手动更改zebra_datepicker.js文件。 在该文件中,基于窗口位置计算日历的位置。 我删除了该计算并在顶部和左侧给出了所需的值我更改了以下代码 h=c(window).width(),l=c(window).height(),f=c(window).scrollTop(),n=c(window).scrollLeft(); 新代码是 h=c(window).width(),l=c(window).height(),f=300,n=463.5; manually change the zebr ... -
datepicker onClose问题(datepicker onClose issue)[2021-07-23]
尝试在第一个datePicker上更改onClose函数 ..., onClose: function( selectedDate ) { var minDate = $(this).datepicker('getDate'); if(minDate){ var newMin = new Date(minDate.setDate(minDate.getDate() + 1)); $( "#datepicker2" ).datepicker( "option", "minDate", ... -
zebra datepicker - 忽略disabled_dates的方向(zebra datepicker - Direction to ignore disabled_dates)[2022-06-23]
我把自己的功能整合在一起。 欢迎反馈:) /* ================================================================================================== BookingForm - Datepicker ================================================================================================== */ $(fun ... -
我最近有同样的问题。 但是有一点延迟(超时)为我解决了这个问题: jQuery(document).ready(function($){ window.setTimeout(function(){ $('input.datepicker').Zebra_DatePicker(); }, 100); }); I recently have the same problem. But a little delay (timeout) solves the issue for m ...
-
开始日期和结束日期是Zebra DatePicker的同一天(Start and end date being the same day of Zebra DatePicker)[2023-02-21]
尝试这个 $('#depart, #departc, #depart_modify').Zebra_DatePicker({ format: 'd/m/Y', selectWeek: true, inline: true, pair: $('#return, #returnc'), firstDay: 1, direction: true // add this line }); $('#return, #returnc, #depart_review'). ... -
Datepicker范围问题(Datepicker range issue)[2022-04-08]
使用以下代码,最小可选日期是1st January of current Year的1st January of current Year最大可选日期是31th December of next Year 。 [试玩] $(function() { var currentYear = new Date().getFullYear(); $( "#datepicker" ).datepicker({ //minDate: new Date(currentYear, 0, 1), mi ... -
jquery UI datepicker月和年只有css定位问题(jquery UI datepicker month and year only css positioning problem)[2023-08-20]
您可以在显示之前操纵datepicker ,但是如果页面上有其他日期选择器,则需要重置它,因为只有1个实际的datepicker。 我创建了一个可能做你想要的演示 。 希望能帮助到你。 HTML Normal:No days:
CSS p { position:absolute; bottom:5px; } div.noDays table { ...如何在zebra datepicker中禁用日期哪个日期来自ajax(how to disabled date in zebra datepicker which date coming through ajax)[2022-03-05]
您可以从项目主页获取的详细配置信息如何在日期选择器中禁用不同日期组的问题,它将作为 $("#datepicker123").Zebra_DatePicker({ direction: true, disabled_dates: [ '05 02 2017', '09 02 2017', '15 02 2017', ] }); 这将禁用2017年2月的第5天,第9天和第15天 所以你的代码就是 $(document) ...相关文章
更多- jQuery ,ajax,中文传值传不到的问题,第一次使用
- jquery ajax方法url请求action没有返回json数据。
- [IT教程网]Ajax和jQuery基础入门视频[已经完结]
- ajax数据安全的问题
- jquery ajax做的项目,如何实时更新当前位置所在的面包屑导航?
- AJAX问题
- 传智播客冯威Ajax和jQuery基础入门视频教程
- ajax验证用户注册
- jquery 问题
- AJAX JSON 乱码
最新问答
更多- python的访问器方法有哪些
- 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
- 透明度错误IE11(Transparency bug IE11)
- linux的基本操作命令。。。
- 响应navi重叠h1和nav上的h1链接不起作用(Responsive navi overlaps h1 and navi links on h1 isn't working)
- 在C中读取文件:“r”和“a +”标志的不同行为(Reading a File in C: different behavior for “r” and “a+” flags)
- NFC提供什么样的带宽?(What Kind of Bandwidth does NFC Provide?)
元素上的盒子阴影行为(box-shadow behaviour on elements) - Laravel检查是否存在记录(Laravel Checking If a Record Exists)
- 设置base64图像的大小javascript - angularjs(set size of a base64 image javascript - angularjs)
- 想学Linux 运维 深圳有哪个培训机构好一点
- 为什么有时不需要在lambda中捕获一个常量变量?(Why is a const variable sometimes not required to be captured in a lambda?)
- 在Framework 3.5中使用服务器标签<%=%>设置Visible属性(Set Visible property with server tag <%= %> in Framework 3.5)
- AdoNetAppender中的log4net连接类型无效(log4net connection type invalid in AdoNetAppender)
- 错误:发送后无法设置标题。(Error: Can't set headers after they are sent. authentication system)
- 等待EC2实例重启(Wait for an EC2 instance to reboot)
- 如何在红宝石中使用正则表达式?(How to do this in regex in ruby?)
- 使用鼠标在OpenGL GLUT中绘制多边形(Draw a polygon in OpenGL GLUT with mouse)
- 江民杀毒软件的KSysnon.sys模块是什么东西?
- 处理器在传递到add_xpath()或add_value()时调用了什么顺序?(What order are processors called when passed into add_xpath() or add_value()?)
- sp_updatestats是否导致SQL Server 2005中无法访问表?(Does sp_updatestats cause tables to be inaccessible in SQL Server 2005?)
- 如何创建一个可以与持续运行的服务交互的CLI,类似于MySQL的shell?(How to create a CLI that can interact with a continuously running service, similar to MySQL's shell?)
- AESGCM解密失败的MAC(AESGCM decryption failing with MAC)
- SQL查询,其中字段不包含$ x(SQL Query Where Field DOES NOT Contain $x)
- PerSession与PerCall(PerSession vs. PerCall)
- C#:有两个构造函数的对象:如何限制哪些属性设置在一起?(C#: Object having two constructors: how to limit which properties are set together?)
- 平衡一个精灵(Balancing a sprite)
- n2cms Asp.net在“文件”菜单上给出错误(文件管理器)(n2cms Asp.net give error on Files menu (File Manager))
- Zurb Foundation 4 - 嵌套网格对齐问题(Zurb Foundation 4 - Nested grid alignment issues)
- 湖北京山哪里有修平板计算机的