Question

I'm developing a PhoneGap application with jQuery Mobile 1.3.2 & jQuery 2.0.3. I have a login form with a username and a password. There is a PHP which accepts the POSTed variables and returns JSON encoded data to allow the login process to proceed.

I use the following JavaScript for the ajax login.

document.addEventListener("deviceready", onDeviceReady, true);
function onDeviceReady() {
    $(function () {
        $("#login_form").submit(function() {
            var postData = $(this).serialize();
            $.ajax({
                type: "POST",               
                data: postData,
                url: "url of PHP file that takes in credentials and sends back json encoded response",              
                success: function(data){    
                    var login_data = JSON.parse(data);
                    if (login_data.success == "go") {
                        $.mobile.changePage("#page2", {transition:"slide", changeHash:false});                  
                    } else if (login_data.success == "no go") {
                        navigator.notification.alert("Email Not Found. Please Register.", function(){}, "Alert", "OK");
                    } else {    
                        navigator.notification.alert("Login Failed. Please Try Again.", function(){}, "Alert", "OK");       
                    }
                },
                error: function(xhr, status, error) {
                    var err = eval("(" + xhr.responseText + ")");
                    navigator.notification.alert(err.Message, function(){}, "Alert", "OK");
                }
            });         
            return false;
        });
    });
}

I'm having an issue when more than one device is connected via the same wifi router. One or the other device will connect and the other will stall and occasionally give the AJAX failed message.

Searching around and asking colleagues I'm whittling down reasons why this is failing. The code works...in isolation. And the code works when two devices are used while connected to two different wifi routers.

At this point my best guess is that because each device is sending out near identical info to the router it goes and returns with the response, but doesn't know which device to return the responses to as they are not individually tagged (perhaps with their individual mac addresses or assigned IP numbers - don't laugh too hard, I'm a networking noob).

Any ideas on what might cause this fail and ways I can go about testing and fixing it?

Was it helpful?

Solution

This turned out to be an unknown issue with the Web Host provider. Despite more than a dozen detailed requests for what on their side was blocking things I was always referred to how my own equipment or own code was at fault.

Set myself up a VPS and presto change-o I have a working system with no modifications to the code or the equipment.

TIL I don't like people who cover up their incompetency by blaming others.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top