Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery blackberry ajax problems
    primarykey
    data
    text
    <p>I have an asp.net web application that I am making available to mobile devices. Im using jQuery and jqMobile for the functionality and styling.</p> <p>The application works great in safari, google chrome, on the iPhone, iPad, and Android devices but I cant get it working on anything other than the Blackberry torch. I have a requirement to get it working on version 5 and 6 blackberry devices but it seems the ajax request for logging in is always calling the error function and I cant see why. </p> <p><img src="https://i.stack.imgur.com/3OoUW.png" alt="enter image description here"></p> <p>The application contains a few pages but I cant even get past the login page on the blackberry. Has anyone else managed to get ajax calls working on the blackberry? I dont really want to have a seperate set of pages just for blackberrys'</p> <p>Here is the code for the login page aspx</p> <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="Sicon.Web.WAP.App.Pages.Mobile.Login" %&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head id="Head1" runat="server"&gt; &lt;title&gt;&lt;/title&gt; &lt;link href="../../JavaScripts/jquery.mobile.min.css" rel="stylesheet" type="text/css" /&gt; &lt;script src="../../JavaScripts/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="../../JavaScripts/jquery.mobile.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="login" runat="server" accept-charset="utf-8"&gt; &lt;div id="Invoices" data-role="page" data-theme="b"&gt; &lt;div data-role="header" data-theme="b"&gt; &lt;h1&gt; WAP - Login&lt;/h1&gt; &lt;/div&gt; &lt;div data-role="content" data-theme="b"&gt; &lt;div align="center"&gt; &lt;img src="Sicon_LogoHz_rgb72.png" /&gt; &lt;/div&gt; &lt;ul data-role="listview" data-inset="true"&gt; &lt;li&gt; &lt;input type="text" value="" name="username" placeholder="Username" id="username" /&gt; &lt;/li&gt; &lt;li&gt; &lt;input type="password" value="" name="password" placeholder="Password" id="password" /&gt; &lt;/li&gt; &lt;/ul&gt; &lt;a class="login" data-role="button" data-theme="b"&gt;Login&lt;/a&gt; &lt;a data-role="button" data-theme="a"&gt;Cancel&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt; &lt;script type="text/javascript"&gt; var _ajaxEnabled = true; $(document).ready(function() { _ajaxEnabled = $.support.ajax; }); //Get base URL var baseUrl = "&lt;%= ResolveUrl("~/") %&gt;"; //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; } } &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>And finally the code behind for the login method:</p> <pre><code>/// &lt;summary&gt; /// Logs in the user /// &lt;/summary&gt; /// &lt;param name="Username"&gt;The username&lt;/param&gt; /// &lt;param name="Password"&gt;The password&lt;/param&gt; /// &lt;returns&gt;&lt;/returns&gt; [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&lt;string, int&gt; )[ HttpContext.Current.Session.SessionID ] = StaticStore.CurrentUser.UserID; return true; } else { return false; } } catch ( Exception ex ) { return false; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload