• Hi,

    If user doesn’t exist, it retrieves a page not found.
    I’m confused as i see nothing wrong about the code and when accessing the URL via browser it returns “email already taken” in json format.

    This is the code below and it registers fine if the user doesn’t exist. But if i fill with an email ou username that it’s already taken, leads to:

    404 https://mydomain.com/api/user/register

    In PhoneGap Server Log.
    Visiting that URL returns:
    {“status”:”error”,”error”:”You must include ‘username’ var in your request. “}

    So it shouldn’t return a 404.

      $(document).ready(function(){
          $("#register").click(function(){
            var display_name = $("#display_name").val();
            var email = $("#email").val();
            var username = $("#username").val();
            var password = $("#password").val();
            $.ajax({
                type: "POST",
                url:"https://domain.com/api/get_nonce/?controller=user&method=register",
                crossDomain: true,
                cache: false,
                success: function(data){
                  var nonce = data.nonce;
                  alert(nonce)
                  var dataString = "username="+username+"&email="+email+"&nonce="+nonce+"&display_name"+display_name+"&user_pass"+password;
                  $.ajax({
                      type: "POST",
                      url:"https://domain.com/api/user/register",
                      data: dataString,
                      crossDomain: true,
                      cache: false,
                      success: function(data){
                        alert(JSON.stringify(data));
                        window.location="https://domain.com";
                      },
                      error: function (jqXHR, exception) {
                        var msg = '';
                        if (jqXHR.status === 0) {
                          alert('Not connect.\n Verify Network.')
                        } else if (jqXHR.status == 404) {
                          alert('Requested page not found. [404]')
                        } else if (jqXHR.status == 500) {
                          alert('Internal Server Error [500].')
                        } else if (exception === 'parsererror') {
                          alert('Requested JSN parse failed.')
                        } else if (exception === 'timeout') {
                          alert('Time outed JSN')
                        } else if (exception === 'abort') {
                          alert('Ajax request aborted.')
                        } else {
                          alert('Uncaught Error.\n' + jqXHR.responseText);
    
                        }
                        
                      },
    
                    });
                  }
    
                });
              });
            });

    Is this related to the fact that its not the pro version of the plugin?

    thanks

  • The topic ‘Page not found if user already exists’ is closed to new replies.