大佬教程收集整理的这篇文章主要介绍了$.active在遵循jQuery代码中意味着什么?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
<script src="jquery-1.9.1.min.js"></script> <script src="jquery-ui-1.10.0.custom.min.js"></script>
现在由以前的开发人员编写的函数如下:
function add_rebate_by_product() { if($.active > 0) { //or $.active //what this $.active does request_inprogress(); } else { var manufacturer_id = $("#company_id").val(); var rebate_no = $('.well').length; var site_url = $('#site_url').val(); if ($('.well').length>=0) { rebate_no = rebate_no+1; } $('.add_new_rebate').attr('disabled','disabled'); } $.ajax({ type: "POST",url: "add_rebate_by_product.PHP",data: {'request_type':'ajax','op':'create_rebate','rebate_no':rebate_no,'manufacturer_id':manufacturer_iD},beforeSend: function() { $('.load_img').html("<img src='"+site_url+"img/ajax-loader.gif' class='load' alt='Loading...'>"); },success: function(data) { if(jQuery.trim(data)=="session_time_out") { window.LOCATIOn.href = site_url+'admin/login.PHP?timeout=1'; } else { $('.rbt').append(data); $('.add_new_rebate').removeAttr('disabled'); //code for state SELEct control to make functionality workable in newly added rebate block $('.states').multiSELEct({ includeSELEctAllOption: true,maxHeight: 150 }); //code for datepicker control to make functionality workable in newly added rebate block $(".date_control").datepicker({ dateFormat: "yy-mm-dd" }); } $('.load').remove(); } }); //} }
现在有人可以解释以下文件的作用以及它的重要性吗?
if($.active > 0) { //or $.active request_inprogress(); }
提前致谢.
它是为ajaxStart()和ajaxStop()启用全局事件处理程序的标志.您可以在here上找到更多详细信息并阅读this问题.
1.
// Counter for holding the number of active queries active: 0,
2.
// Watch for a new set of requests if ( fireGlobals && jQuery.active++ === 0 ) { jQuery.event.trigger("ajaxStart"); }
3.
// Handle the global AJAX counter if ( !( --jQuery.active ) ) { jQuery.event.trigger("ajaxStop"); }
以上是大佬教程为你收集整理的$.active在遵循jQuery代码中意味着什么?全部内容,希望文章能够帮你解决$.active在遵循jQuery代码中意味着什么?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。