2

How can I override Drupal.ajax written in misc/ajax.js?

I need to check URL existence before firing an AJAX call.

Is there any other way/better way to achieve that without overriding this js?

Thanks

Parth Vora
  • 3,903
  • 6
  • 33
  • 56

1 Answers1

0

I don't know about Drupal.ajax but this Jquery Method is the way to go:
$(document).ajaxSend(function(event, jqxhr, settings){ if ( settings.url == "some urls" ) {//checks if related url should be checked or not. //Do Something likeThis url checkingor what ever you want. if(!UrlExists(settings.url)){ jqxhr.abort(); } } });

Be careful, This method is a global ajax event -- so this effectively can filter all ajax requests.

Community
  • 1
  • 1
Rzassar
  • 1,838
  • 27
  • 47