Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery Mobile - is there a way to turn off AJAX for the whole page?

I am converting an existing ASP.NET website to use jQuery Mobile controls. The first thing I did was replace the Login.aspx with the new Masterpage and mobile controls. However, now after the login occurs, in the code-behind, there is a Response.Redirect to Default.aspx. When that occurs, a javascript error occurs and the whole page dumps and fails to load.

My assumption is that the mechnanism(s) in jQuery mobile that try to AJAX everything are not playing nicely with scripts that MS.NET is producing. So I want jQuery to ignore the redirect and not AJAXify it.

The problem is, all the solutions I see have to do with adding code to the anchor tag, but I'm redirecting from behind, not using an anchor tag.

like image 474
Todd Davis Avatar asked Dec 02 '22 02:12

Todd Davis


2 Answers

Add the attribute data-ajax="false" to the <form> tag on the page. That way when the login form is submitted, jQuery Mobile won't try to update the page using AJAX.

like image 57
Greg Avatar answered Dec 04 '22 02:12

Greg


If you are using jQuery mobile then you can use following code to disable ajax through the page.

<script>
   $.mobile.ajaxEnabled = false;
</script>
like image 26
sachin kulkarni Avatar answered Dec 04 '22 00:12

sachin kulkarni