0

Is there any way to disable ajax in jQuery for just one page? I've read the documentation but the code supplied disables ajax on all links and forms. And I've seen too that on earlier versions you could disable just forms. Is there any way to call that function in latest versions? Thanks

Kiran
  • 20,167
  • 11
  • 67
  • 99
ERed
  • 628
  • 4
  • 18
  • 3
    "disable ajax"? If you don't want ajax on a page, then don't include any ajax-related code on that page. – Marc B Sep 06 '13 at 15:18
  • 1
    Can't you just not use any ajax on that one page? – musefan Sep 06 '13 at 15:18
  • 2
    It's unclear what you're asking for. – j08691 Sep 06 '13 at 15:19
  • 1
    You can't disable ajax just for forms, as a form does not make ajax calls - an event handler does. Explain what your problem is, what you're trying to do, and show us any relevant code :o) – Reinstate Monica Cellio Sep 06 '13 at 15:20
  • I'm registering jQuery mobile via wordpress, so jQuery treats all the links and submit forms as ajax requests, but some requests can't be treated as ajax requests. So I know I could add an attribute to the form: ajax enabled=false, but I'm looking for an easier way to do this by maybe catchind the page id and disable ajax just on that page. Do you understand? – ERed Sep 06 '13 at 15:21
  • @marcb this is jquery mobile. It's based on Ajax navigation. – Omar Sep 06 '13 at 17:58

1 Answers1

0

However, sometimes we need to be able to submit our forms without using AJAX. Depending on what we are doing with our forms, AJAX can actually cause errors and problems.

1. Disable AJAX on an individual form basis In this method we are going to give the tag a data attribute that tells the form not to use AJAX upon submit. We disable AJAX by passing the data-ajax=”false” data attribute to the <form>tag. It will look like<form action=”" method=”" data-ajax=”false”></form>.

2. Disable AJAX globally for all forms and page navigation We also have the option to disable AJAX on a global scope that prevents jQuery Mobile from using AJAX for it’s page navigation or for form submission. We do this by placing some simple JavaScript code into the header of our jQuery Mobile app. Essentially we are using jQuery Mobile API’s to disable AJAX.

$(document).bind(“mobileinit”, function() { $.mobile.ajaxEnabled = false; });

source: http://blog.linuxacademy.com/jquery-mobile/tip-disable-ajax-on-jquery-mobile-forms/

Community
  • 1
  • 1
Kiran
  • 20,167
  • 11
  • 67
  • 99
  • Way to plagiarize: http://blog.linuxacademy.com/jquery-mobile/tip-disable-ajax-on-jquery-mobile-forms/#more-2239 – j08691 Sep 06 '13 at 15:23
  • I already knew that, but thaks anyway. What I want, if it is possible is to catch some page id and disable all ajax from that page, for links and submits. – ERed Sep 06 '13 at 15:24
  • Instead of `$(document).bind(“mobileinit”, function() { $.mobile.ajaxEnabled = false; });` use same code while loading DOM for which pages that you would like to block ajax. – Kiran Sep 06 '13 at 15:27
  • I've tried `$(document).bind(“pageinit”,"#pageid", function() { $.mobile.ajaxEnabled = false; });`but it is not working. – ERed Sep 06 '13 at 15:29
  • Hope this helps you. http://stackoverflow.com/questions/14740041/jquery-mobile-pageinit-event-not-fired – Kiran Sep 06 '13 at 16:42