Ajax does not work on the server

Asked

Viewed 282 times

1

I read some answers in the forum, but none managed to solve my problem, Ajax works in place, but when I go up it just doesn’t work, follow the code:

jQuery('#formLogin').submit(function(){
    var dados = jQuery( this ).serialize();

    jQuery.ajax({
        type: "POST",
        url: "script/logar.php",
        data: dados,
        success: function( data ) {
            var y = data.length;

            if (y == 9) { 
                window.location.href = "editar-perfil.php";
            }
            return false;
        }
    }
});
  • can pass the url of the project?

  • http://aguamkt.com.br/perfil.business/login.php

  • Looking at the return of the request appears the following error. PHP Warning: mysqli_connect(): (HY000/2002): The requested address is not valid in context. in D: web localuser aguamkt www profile.business script bd.php on line 2 You are unable to connect to the database. Take a look at this db.php file

  • Most likely you have not configured the connection file correctly.

  • I also tested, and I came up with this mistake POST http://aguamkt.com.br/perfil.business/script/logar.php 500 (Internal Server Error)

  • Really, silly mistake my, thank you very much! Solved

  • When using ajax you have to monitor those "silly mistakes" you say. A F12 > network help if you’re in Chrome.

Show 2 more comments
No answers

Browser other questions tagged

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