Ajax not running Event sucess

Asked

Viewed 38 times

0

I received complaints from some customers that the site was not completing the order, but when checking the code I did not find anything else and for me it works perfectly. The ajax code is this

$.ajax({
                type      : 'POST', 
                url       : 'www.site.com/functions.php', 
                data      : {func: func, nome: nome, email: email, cel: cel, tamanho: tamanho, modelo: modelo, valor: valor}, 
                dataType  : 'json',
                timeout   : 30000,
                cache: false,
                beforeSend: function(){
                  $('div.loading').fadeIn(400);
                },
                complete: function(response){
                  $('div.loading').fadeOut(400);
                  avancar_container(id);
                  alert(response);
                },
                success: function(response){
                  $('div.loading').fadeOut(400);
                  avancar_container(id);
                  alert(response);
                },
                error: function(response){
                  alert(response);
                }
            }); 

the strange thing is that the request is registered in the database, which discards me error in php, but the person does not receive the success message.

  • Is the data generated in the database correctly? Have you tried leaving some fields unfilled? What error and complete return? Already checked the error logs from php and your server? Is the request running out of time? Have you checked the console tab of the "Element Inspector" or similar?

  • The data in bd is correct, jquery and php check fields. The message returns php echo correctly. The timeout I’m testing now, and it looks functional. The logs and inspector still haven’t looked

  • You have two alert() after the return? the complete will always run at the end, either of success or error. As it has the same instructions from success, will you not be confusing?

  • I put the complete after to see if it worked, but it didn’t work, I forgot to change when I published.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.