0

I have a problem. I'm developing a website for my photos. The registration is working well on computer, but I have some problems on my mobile device (android).

I'm using jquery ajax:

beforeSend: function(){
$("#load").css({"display":"block"});
}

The beforeSend function should display the loader div with a loading.gif. On Computer browser it is working well, but on my mobile device it doesn't hide and the success message does not show. It all works perfectly on computer browser. Perhaps you can help me.

This is the whole jquery code:

$(":button").click(function(e){

    e.stopImmediatePropagation();

      var benutzername = $("input[name=benutzername]").val();
      var passwort = $("input[name=passwort]").val();
      var email = $("input[name=email]").val();


      var characterReg = /^[A-Za-z0-9_]{5,20}$/;
        if(!characterReg.test(benutzername)) {
            $("input[name=benutzername]").val("");
            $(".text-input:nth(0)").html("Mindestens 5 Buchstabend, Zahlen. Keine Sonderzeichen oder Umlaute.");
                $("input[name=benutzername]").focus(function(){
                    $(".text-input:nth(0)").html("");
                });

        }else{
            var emailReg = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
            if(!emailReg.test(email)) {
                $("input[name=email]").val("");
                $(".text-input:nth(1)").html("Gebe bitte eine richtige E-Mail Adresse an.");
                    $("input[name=email]").focus(function(){
                        $(".text-input:nth(1)").html("");
                    });

            }else{
                var passwortReg = /^[A-Za-z0-9!@#$%^&*()_]{6,20}$/;
                    if(!passwortReg.test(passwort)) {
                        $("input[name=passwort]").val("");
                        $(".text-input:nth(2)").html("Mindestens 6 Zeichen plus Sonderzeichen (!@#$%^&*()_). Keine Umlaute");
                            $("input[name=passwort]").focus(function(){
                                $(".text-input:nth(2)").html("");
                            });

                    }else{
                        if ($('input:checkbox').is(':checked')) {
                               $.ajax({
                                    type: "POST",
                                    url: "register/register.php",
                                    data: "benutzer="+benutzername+"&pass="+passwort+"&mail="+email ,
                                    cache: false,
                                    beforeSend: function(){

                                        $("#load").css({"display":"block"});
                                    },
                                    error:function(){
                                      alert("ERROR");
                                    },
                                    success: function(html){

                                    if(!html.contains("entry")){
                                        //$("#outer").css({"display":"none"});
                                        //$("#outer").css({"display":"none"});
                                        $("#outer").hide();
                                        $("#successregister").css({"display":"block"});
                                    }

                                    if(html.contains("for key 'email'")){
                                        $(".text-input:nth(1)").html("Email Adresse schon vorhanden.");
                                        $("input[name=email]").focus(function(){
                                            $(".text-input:nth(1)").html("");
                                        });
                                    }

                                    if(html.contains("for key 'benutzername'")){
                                        $(".text-input:nth(0)").html("Benutzername schon vorhanden.");
                                        $("input[name=benutzername]").focus(function(){
                                            $(".text-input:nth(0)").html("");
                                        });
                                    }




                                        $("#load").fadeOut('1500', function(){
                                            $("#load").css('display','none');
                                            $("#loadgif").css('display','none');
                                        });


                                    }
                                });
                        }else{
                            $(".text-input:nth(2)").html("Bitte Akzeptieren Sie die AGB's");
                            $('input:checkbox').focus(function(){
                                $(".text-input:nth(2)").html("");
                            });




                        }


                    }
            }


        }



        e.preventDefault();

     });

And this is the html code:

<div id="outer">
<div id="page-content">

    <div id="left">
    Hier kannst du dich Registrieren und damit folgende Vorteile freischalten:
    <ul>
        <li>Kommentieren von Fotos.</li>
        <li>Lizenkauf von Fotos.</li>
        <li>Fragen zum Foto stellen.</li>
        <li>uvm.</li>

    </ul>
    Das Konto ist kostenfrei, bitte gebe deine korrekten Daten ein sonst kannst du dein Konto nicht aktivieren.


    </div>

    <div id="register-form">
        <div id="clearfix">
            <div id="f55990">Konto erstellen </div>
            <div id="f55991">oder <a href="?do=login">anmelden.</a></div>
        </div>
        <form method="post" action="" name="regform">
            <input type="text" name="benutzername" placeholder="Benutzername" />
            <div class="text-input-error text-input"></div>
            <input type="email" name="email" placeholder="Email@adresse.de" />
            <div class="text-input-error text-input"></div>
            <input type="password" name="passwort" placeholder="Passwort" />
            <div class="text-input-error text-input"></div>
            <input type="checkbox" name="agreeagb" value="agb"   />
            <div class="checkbox">
                <label for="agreeagb">
                    <span>Ich stimme den <a target="_blank" href="?show=test">Nutzungsbedingungen</a> zu.</span>
                </label>
            </div>
            <!-- <input type="submit" name="absenden" value="Absenden"/> -->
            <button name="absenden">Absenden</button>
        </form>
    </div>
</div>

<div id="successregister" style="display: none;">
<img src="register/images/tick.png" />Die Registration war erfolgreich. Bitte &uuml;berpr&uuml;fe dein E-Mail-Postfach<br />
und aktiviere dein Konto. Dein Konto wird anstonsten nach zwei Tagen gel&ouml;scht.

The website: de-photographie.eu

Greetings from Berlin, germany.

  • Is it possible the styling on #load container isn't behaving as expected? Just a guess, have no data on #load html, CSS, jQuery – dajoto May 02 '15 at 22:14
  • Normaly when the user is registred and clicked on 'Absenden' the #load should displayed. It is working on Desktop Browser only at the mobile phone it is not working. –  May 02 '15 at 22:51
  • it is working with @4ega 's solution. –  May 02 '15 at 23:37

1 Answers1

0

There is a problem with your code, string does not have method 'contains'.

if(!html.contains("entry")){

In Firefox 18 - 36, the name of this method was called "contains". It was renamed to "includes"

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes#String.prototype.contains

Use indexOf instead, like it mentioned here How to check whether a string contains a substring in JavaScript?

Community
  • 1
  • 1
4ega
  • 1,992
  • 2
  • 12
  • 15