$("button#lb").click(function(g){
                     g.preventDefault();
                     
    $.ajax({
               type: "POST",
 url:myloc + '/lgn.php',
  cache: false,
 data: $("#lf").serialize(),
         success: function(msga){
if(msga.split('|')[0] == "ok"){
setTimeout(function() {
            $("#lm").html(msga.split('|')[1]);
            $("#lf")[0].reset();
    window.location.reload();
  }, 3000);
} else {
alert("hatali sifre");
}
  },
 error: function(jqxhr, textStatus, line){
      var err = jqXHR.status + ", " + line;
        alert(err);
 }
       });
});
php koduna da, giriş başarılı ise gönderilen veriden önce "ok|" göndermesini sağlayın (tırnaklar yok)