strange ajax login issue with android and iOS

Discussion in 'Troubleshooting' started by easyprompter, Jul 8, 2017.

Thread Status:
Not open for further replies.
  1. easyprompter

    easyprompter New Member

    Joined:
    Oct 4, 2016
    Messages:
    12
    I am implementing an AJAX login form on my site and I noticed a weird android issue. When I first try to log in, it returns with "TypeError: Cannot create property 'error' on string". then i try this on an iPad and instead i get an error "TypeError: Attempted to assign to readonly property"

    I don't know where this error is coming from but trying to debug it, it appears that amember/login is not treating the request correctly.. instead of returning an ajax response, it returns the html of the login page.
    anyway, if I then go to amember/login directly and without doing anything just hit the back button, then all subsequent login requests work just fine

    this is thoroughly confusing me - is there a way to force the amember/login page to return the proper json object instead of the HTML for the login page?
  2. easyprompter

    easyprompter New Member

    Joined:
    Oct 4, 2016
    Messages:
    12
    followup - i was about to resolve at least some of the issues by moving from $.post to $.ajax and specifying
    the following:
    Code:
                           accepts: {
                                json: 'application/json'
                            },
                            method: 'POST',
                            headers: {
                                'X-Requested-With': 'XMLHttpRequest'
                            },
                            url: frm.attr('action'),
                            data: formData,
                            dataType: 'json'
    however, now it redirects me back to my home page first time around and then subsequent logins work fine.. it's a little better but still not 100%
  3. easyprompter

    easyprompter New Member

    Joined:
    Oct 4, 2016
    Messages:
    12
    response comes back {ok: true, url: "https://www.mysite.com/"} so it would seem login worked but the session does not get logged in until second time
  4. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    1,642
  5. easyprompter

    easyprompter New Member

    Joined:
    Oct 4, 2016
    Messages:
    12
  6. easyprompter

    easyprompter New Member

    Joined:
    Oct 4, 2016
    Messages:
    12
    Got my answer from support - turned out to be a CORS issue. I didn't realize my site wasn't redirecting to https automatically.
    a simple .htaccess update fixed it
    thanks!
    caesar likes this.
Thread Status:
Not open for further replies.

Share This Page