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

こ雲淡風輕ζ 提交于 2019-12-22 08:48:15

问题


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.


回答1:


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.




回答2:


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

<script>
   $.mobile.ajaxEnabled = false;
</script>



回答3:


Refer the JQueryMobile documentation here

The easiest way would be to have this , ajaxFormsEnabled :false



来源:https://stackoverflow.com/questions/6697959/jquery-mobile-is-there-a-way-to-turn-off-ajax-for-the-whole-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!