$ .ajax locking the server

0

I'm trying to make an application with the phonegap and I have the following problem.

As an example, I have the following function:

function listar(){

    var useremail = localStorage.getItem('email');
    var userpassword = localStorage.getItem('pass');
    var acao = "listar";



    $.ajax({
        type: 'POST',
        url: 'http://www.site.com/funcoes.php',
        data: {useremail : useremail, userpassword : userpassword, acao : acao},
        beforeSend: function() {
            // Loading function...
            document.getElementById('loadfunc').style.display = "block";
        },
        success: function(data) {
            $("#wrapper-home").html(data);
        },
        error: function(xhr) { // if error occured

            alert("falha ao carregar");      

        },
        complete: function() {
           document.getElementById('loadfunc').style.display = "none";
        },
        dataType: 'html'
    });


}

I was testing the following - I click the button that calls this function and when finished loading I click again. After clicking a few times it starts to fall into the error function.

Funny that using my pc as a server I click endless times and it does not give an error, it was only to go to the hosting service and started giving the problem.

Would anyone have any light of what it could be? Something I can add in the function to know the exact error it is giving or even some configuration on the server that needs to be done. (I'm using godaddy).

Thank you!

    
asked by anonymous 20.08.2016 / 00:59

1 answer

0

What kind of server are you using? shared hosting, VPS, dedicated server?

It may happen that the server interprets all of these requests as a DDoS attack, hence to prevent it from allowing access, but there may be many other reasons for this. Then do the following, la in your error function puts it so to show what the error is and see what it is returning:

error: function(xhr) { // if error occured

        alert(JSON.stringify(xhr));      

    }
    
20.08.2016 / 22:27