tigger tigger
tigger tigger

Reputation: 109

Redirection not working with JQuery Mobile

I am running a DNN7.1 website. I have a regular website. I added a page which acts as login page for mobile users. I am using JQuery Mobile 1.3.2 on the mobile pages including this mobile login page. If the user navigates to that page and enters username and password, it works correctly and redirects them to the correct page sent on the url using a querystring, example:

http://localhost/Mobilelogin?url=http://localhost/somePage 

it correctly redirects to

http://localhost/somePage

Now I want to add capability where user can directly send his username and password along with the url that he wants to navigate, the login page should authenticate using the username and password provided and once successful redirect it to the url (using asp.net Response.Redirect method), in the format

http://localhost/Mobilelogin?u=username&p=password&url=http://localhost/somePage 

The issue is, it works fine if the user is not logged in but if he is already logged in and then uses the same url, (which has username and password) redirection doesn't work. I tried disabling the ajax using following code, as I read redirection and JQM doesn't work well.

$(document).on("mobileinit", function () {
$.extend($.mobile, {
linkBindingEnabled: false,
ajaxEnabled: false
});
}); 

But it still is not working. Can anyone please let me know what I need to do to make this work.

I tried debugging the login module, which is written in c#, when the user enters the url when not logged in, it calls the page load and hits the break point but when logged in and enters the url the break point is never hit. It looks like browser is not even contacting the server. I am new to JQM, I thought disabling the ajax globally will always hit the server to get the information. Is that not how it works? How can I make the redirection work in my case. Any help is greatly appreciated.

Upvotes: 0

Views: 468

Answers (1)

sh1rts
sh1rts

Reputation: 1884

You need to be aware that by default, jQuery Mobile uses AJAX to load page content and does not "redirect" as per normal.

You should read the FAQ's as these provide useful information: -

http://view.jquerymobile.com/1.3.2/dist/demos/faq/

Specifically: -

.. it will only inject the contents of the response's body element (or more specifically the data-role="page" element, if it's provided), meaning nothing in the head of the page will be used

http://view.jquerymobile.com/1.3.2/dist/demos/faq/scripts-and-styles-not-loading.html

This might explain why your script doesn't execute, as if it's in the <head> it's not being loaded.

Upvotes: 1

Related Questions