Im beginner and have just simple PHP MVC for JQUERY SPA, and just wonnt to use Jquery Ajax to index.php, like front controller calling RouterControler and class AjaxKontroler with registruj() method...using user model to add new user to MySQL..
class AjaxKontroler
{
public function registrovat()
{
if ($_POST)
{
try
{
$spravceUzivatelu = new SpravceUzivatelu();
$spravceUzivatelu->registruj($_POST['email'],$_POST['heslo'],$_POST['hesloZnovu'],$_POST['jmeno'],$_POST['prijmeni'],$_POST['telefon'],$_POST['ulice'],$_POST['mesto'],$_POST['psc'],$_POST['captcha']);
$spravceUzivatelu->prihlas($_POST['email'], $_POST['heslo']);
}
catch (ChybaUzivatele $chyba)
{
$this->pridejZpravu($chyba->getMessage());
}
}
echo "Registrace proběhla úspěšně";
}
Singup form:
$("#dokoncitregistraci").click(function () {
var email = $("#emailreg").val();
var heslo = $("#hesloreg").val();
var hesloznovu = $("#hesloznovureg").val();
var jmeno = $("#jmenoreg").val();
var prijmeni = $("#prijmenireg").val();
var telefon = $("#telefonreg").val();
var ulice = $("#ulicereg").val();
var mesto = $("#mestoreg").val();
var psc = $("#pscreg").val();
var captcha = $("#captcha").val();
console.log("jedu");
$.ajax({
type: "POST",
url: "../ajax/registrovat",
data: {
"email" : email,
"heslo": heslo,
"hesloznovu" : hesloznovu,
"jmeno" :jmeno ,
"prijmeni":prijmeni,
"telefon":telefon,
"ulice":ulice,
"mesto" :mesto,
"psc" : psc,
"captcha" :captcha
},
dataType: "JSON",
success: function(msg){
alert("msg");
}
But all signup inputs are correctly add ti MySQL like new row. I have no success response to work with. Are there some trick to use success response in MVC?
Browser just doesn't make any JS alert(). Sorry abeout using StackOwerflow, its my first question here ane no best practise for it:)