פורסם 2010 בדצמבר 714 שנים הי,אני מבצע קריאות AJAX עם JQUERY כאשר משתמש לוחץ על כפתור מסויים. הכל עובד טוב רוב הזמן אבל מידי פעם לחיצה על הכפתור גורמת ל - 2 קריאות AJAX במקום אחת. ניסיתי לגרום לכפתור להפוך ל DISABLED מיד אחרי הלחיצה ולפני ביצוע הקריאה ל -AJAX כדי למנוע מצב של לחיצה פעמיים אבל זה לא עזר.אשמח לעזרה.תודה.
פורסם 2010 בדצמבר 714 שנים מחבר יש לי אובייקט עם מתודה UPDATE:update : function(data, url) { $.ajax( { url : url, type : "POST", data : data, success : function(html) { // appendResponse(html); alert('Updated!'); }, error : function(html) { // handleError(html); alert('Error!'); } }); }וההגדרה של CLICK:$('button').click(function(){object.update(data,url)})[br]פורסם בתאריך: 7.12.2010 בשעה 12:49:40דבר נוסף ששכחתי לציין, כשאני מסתכל ב- FB אני רואה את 2 הקריאות ואני רואה שהם קיבלו RESPONSE נכון, כלומר לכאורה הקריאות מצליחות אבל אני חוטף TIMEOUT (הגדרתי אותו ל -3 שניות).אם אחרי ה - TIMEOUT אני לוחץ שוב, זה מצליח.
פורסם 2010 בדצמבר 1114 שנים מחבר הסנריו הוא שיש טבלה עם נתונים וליד כל נתון יש כפתורי EDIT/DELETE כשמשתמש לוחץ על EDIT, אני מביא את המידע עם AJAX ופותח DIALOG. HTML: <!--filter start--><div id="filter"> <div class="tabfilter" id="tabfilter"> <img src="/dort/assets/css/images/i_plus_filter.gif" class="marb5" /> Filter by</div> <div class="filter_view">View <strong id="curr_result"></strong> from <strong id="total"></strong> Campaign Types</div> <div class="float_right" style="margin-bottom:-4px;" > <div class="bg_add_new" id="add" data-link="<?php echo base_url()?>campaign_type/add" onMouseover="this.className='bg_add_new_hover';" onMouseout="this.className='bg_add_new';"> + Add New</div> </div></div><div id="filter_open" id="filter_open"> <div class="filter_open_content"> <div class="float_left marb10"> <div class="float_left w110">Name</div> <label class="float_left w110">Contains</label> <input name="" id="name" data-col="col_name" type="text" value="" class="mform140" /> </div> </div></div><!--filter ends--><!--list start--><table cellpadding="0" cellspacing="0" id="table"> <thead> <tr> <th class="w40"></th> <?php foreach ($headers as $header):?> <th class="sortable"> <a href="#" class="sortable"><?php echo $header?></a><img src="<?php echo ($header === 'Last Updated')?'/dort/assets/css/images/arrow_yello_down.gif':'/dort/assets/css/images/sorting_down.gif';?>" class="i_sorting" /> </th> <?php endforeach;?> <th colspan="2"><div align="center">Action</div></th> </tr> </thead> <tbody> <?php foreach ($cmp_types as $type):?> <tr> <td class="w40"></td> <td class="col_name"><?php echo $type->campaignTypeName;?></td> <td><?php echo $type->campaignStrategyName;?></td> <td><?php echo ($type->disabled === chr(0x01))?'Not Active':'Active';?></td> <td><?php echo $type->updateDate;?></td> <td class="w100"> <a href="<?php echo base_url();?>campaign_type/edit/<?php echo $type->campaignTypeId;?>" class="b_view" onMouseover="this.className='b_view_hover';" onMouseout="this.className='b_view';"> <img src="<?php echo $base_url;?>assets/css/images/pix.gif" alt="View" border="0" /></a> </td> <td class="w100"> <a href="<?php echo base_url();?>campaign_type/delete/<?php echo $type->campaignTypeId;?>"" id="delete" class="b_delete" onMouseover="this.className='b_delete_hover';" onMouseout="this.className='b_delete';"> <img src="<?php echo $base_url;?>assets/css/images/pix.gif" alt="Delete" Title="Delete" border="0" /> </a> </td> </tr> <?php endforeach;?> </tbody></table><!--end list--><div style="clear: both"></div><!--paging--><div class="paging_bottom"> <div class="float_left"> <img src="<?php echo $base_url;?>assets/css/images/but_prev_dis.gif" alt="Previous" border="0"/> </div> <div id="paging"></div> <div class="float_left"> <img src="<?php echo $base_url;?>assets/css/images/but_next_on.gif" alt="Next" border="0" /> </div></div><!--end paging--><!-- ui-dialog --> <div id="dialog_edit" title="View"> </div> <div id="dialog_add" title="Create"> </div> JS: $('#dialog_edit').dialog({ autoOpen: false, width: 400, modal:true, resizable: false });$('tbody tr td a').live('click',function(){ var $edit = $('#dialog_edit'); $.ajax( { url : this.href, type : "get", //on success open the form in a modal dialog success : function(html) { $edit.html(html); $edit.dialog('open'); $('#edit_form').validate({ errorClass: 'error_txt2', errorElement: 'div', rules: { name : { required : true, minlength : 2 }, strategy : { selectNone : true } } }); }, error : function(xhr, status, err) { }, beforeSend : function() { }, complete : function() { }, timeout : 3000 }); return false; }); כמו שאמרתי, רוב הזמן זה עובד בסדר, אבל מידי פעם, כשלוחצים על EDIT, נשלחות 2 בקשות AJAX ואני חוטף TIMEOUT
ארכיון
דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.