Problems with jQuery blackberry ajax

I have an asp.net web application that I provide to mobile devices. Im uses jQuery and jqMobile for functionality and style.

The application works fine in safari, Google Chrome, on iPhone, iPad and Android devices, but I canโ€™t get it to work for anything other than the Blackberry torch. I have a requirement to make it work on BlackBerry devices versions 5 and 6, but it seems like the ajax login request always calls an error function, and I cannot understand why.

enter image description here

The application contains several pages, but I canโ€™t even go through the Blackberry login page. Has anyone else been able to receive ajax calls running on a blackberry? I really don't want to have a separate set of pages for Blackberrys only.

Here is the code for aspx login page

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="Sicon.Web.WAP.App.Pages.Mobile.Login" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title></title> <link href="../../JavaScripts/jquery.mobile.min.css" rel="stylesheet" type="text/css" /> <script src="../../JavaScripts/jquery.min.js" type="text/javascript"></script> <script src="../../JavaScripts/jquery.mobile.min.js" type="text/javascript"></script> </head> <body> <form id="login" runat="server" accept-charset="utf-8"> <div id="Invoices" data-role="page" data-theme="b"> <div data-role="header" data-theme="b"> <h1> WAP - Login</h1> </div> <div data-role="content" data-theme="b"> <div align="center"> <img src="Sicon_LogoHz_rgb72.png" /> </div> <ul data-role="listview" data-inset="true"> <li> <input type="text" value="" name="username" placeholder="Username" id="username" /> </li> <li> <input type="password" value="" name="password" placeholder="Password" id="password" /> </li> </ul> <a class="login" data-role="button" data-theme="b">Login</a> <a data-role="button" data-theme="a">Cancel</a> </div> </div> </form> <script type="text/javascript"> var _ajaxEnabled = true; $(document).ready(function() { _ajaxEnabled = $.support.ajax; }); //Get base URL var baseUrl = "<%= ResolveUrl("~/") %>"; //Function to resolve a URL function ResolveUrl(url) { if (url.indexOf("~/") == 0) { url = baseUrl + url.substring(2); } return url; } //Login form Login link click $("#login a.login").click(function (e) { //Get the form var $form = $(this).closest("form"); //Perform login return app.login($form); }); //Login form submit $("#login").submit(function (e) { //Get the form var $form = $(this); //Perform login return app.login($form); }); //class to handle login var app = { login: function ($form) { var $Username = $("#username").val(); var $Password = $("#password").val(); //Call the approve method on the code behind $.ajax({ type: "POST", url: ResolveUrl("~/Pages/Mobile/Login.aspx/LoginUser"), data: "{'Username':'" + $Username + "', 'Password':'" + $Password + "' }", //Pass the parameter names and values contentType: "application/json; charset=utf-8", dataType: "json", async: true, error: function (jqXHR, textStatus, errorThrown) { alert("Error- Status: " + textStatus + " jqXHR Status: " + jqXHR.status + " jqXHR Response Text:" + jqXHR.responseText) }, success: function (msg) { if (msg.d == true) { window.location.href = ResolveUrl("~/Pages/Mobile/Index.aspx"); } else { //show error alert('login failed'); } } }); return false; } } </script> </body> </html> 

And finally, the code for the login method:

 /// <summary> /// Logs in the user /// </summary> /// <param name="Username">The username</param> /// <param name="Password">The password</param> /// <returns></returns> [WebMethod, ScriptMethod] public static bool LoginUser( string Username, string Password ) { try { StaticStore.CurrentUser = new User( Username, Password ); //check the login details were correct if ( StaticStore.CurrentUser.IsAuthentiacted ) { //change the status to logged in StaticStore.CurrentUser.LoginStatus = Objects.Enums.LoginStatus.LoggedIn; //Store the user ID in the list of active users ( HttpContext.Current.Application[ SessionKeys.ActiveUsers ] as Dictionary<string, int> )[ HttpContext.Current.Session.SessionID ] = StaticStore.CurrentUser.UserID; return true; } else { return false; } } catch ( Exception ex ) { return false; } } 
+6
jquery jquery-mobile blackberry-simulator
source share
2 answers

You do not say which version of jqmobile you are using. Version 4.1 was released on April 7th. You must remember that jqmobile is not yet released in Beta, and that BB OS 5 is listed as B-grade (http://jquerymobile.com/gbs/), so it gets less attention.

You probably have another ajax application in your application, but the login is so simple, why not restructure it as a simple form post?

In addition, the assumption that BB5 is a problem:

https://github.com/jquery/jquery-mobile/issues/1245

+2
source share

Finally, after one week of intense frustration, I got a solution ....

You need to allow cross domain access in your browser browser as follows.

 BrowserFieldConfig config=new BrowserFieldConfig(); config.setProperty(BrowserFieldConfig.NAVIGATION_MODE,BrowserFieldConfig.NAVIGATION_MODE_POINTER); config.setProperty( BrowserFieldConfig.JAVASCRIPT_ENABLED, Boolean.TRUE ); config.setProperty(BrowserFieldConfig.ALLOW_CS_XHR, Boolean.TRUE);//allow cross-domain browser=new BrowserField(config); 
0
source share

All Articles