4

My jquery call is as below on textbox.I want to prevent ajaxStart() on this selector

$("#ddl_select").keyup(function() { var searchid = $(this).val(); var dataString = 'search='+ searchid; if(searchid!='') { $.ajax({ type: "POST", url: "searchname.php", data: dataString, cache: false, success: function(html) { $("#result").html(html).show(); } }); } }); 

I want to prevent ajaxStart() method in above selector.

ajaxStart() code as below

jQuery(document).ajaxStart(function () { //show ajax indicator ajaxindicatorstart(); }).ajaxStop(function () { //hide ajax indicator ajaxindicatorstop(); }); 

Only prevent ajaxStart Method but whole function works as it as.

can anybody help me...

6
  • did you try preventDefault? Commented Jun 20, 2015 at 3:53
  • Or jQuery(document).not('#ddl_select').ajaxStart(function ()? Commented Jun 20, 2015 at 3:55
  • @NightOwlPrgmr in function what can i specify ? Commented Jun 20, 2015 at 3:58
  • How many different AJAX calls do you have? Commented Jun 20, 2015 at 4:01
  • ajaxStart() for loading and ajax on button click event and textbox keyup event. Commented Jun 20, 2015 at 4:04

1 Answer 1

1

I would suggest putting ajaxindicatorstart(); and ajaxindicatorstop(); inside each individual AJAX request except for the selector you didn't want to start it on.

Example:

$.ajax({ type: "POST", url: "searchname.php", data: dataString, cache: false, beforeSend: function() { // start the indicator right before the AJAX call fires ajaxindicatorstart(); }, success: function(html) { // stop the indicator and show the result ajaxindicatorstop(); $("#result").html(html).show(); } }); 
Sign up to request clarification or add additional context in comments.

Comments