mam problem z przesłaniem danych wygenerowanych poprzez php do jquery a następnie wyświetlenia ich w smartach
Kod
if(isset($_POST['logIn'])){
$checkLogIn = $this->config->logIn(); // sprawdzanie usera i nadawanie uprawnienien
echo json_encode($checkLogIn); // wysylanie danych do jquery
}
$checkLogIn = $this->config->logIn(); // sprawdzanie usera i nadawanie uprawnienien
echo json_encode($checkLogIn); // wysylanie danych do jquery
}
teraz jquery
Kod
$('#logInUser').click(function(){ //validation new report
var infoAjax = $('#infoAjax');
var bgAjax = $('#bgAjax');
$.ajax({
url: 'index.php',
dataType: 'JSON',
type: 'POST',
data: $('#form').serialize() + '&logIn=oo',
beforeSend: function(){
infoAjax.html('Trwa logowanie do systemu raportowania błędów<br /><img src="img/loading.gif">').css({'width':'400px',' position':'fixed','left':'50%'}).show();
bgAjax.show();
},
success: function(obj){
infoAjax.html(obj.info);
if(obj.check == 1){
setTimeout(function() {
location.replace(obj.link); //load to new page after logIn
}, 2500);
}else{
setTimeout(function() {
infoAjax.fadeOut();
bgAjax.fadeOut();
}, 2500);
}
},
error : function(){
infoAjax.html('<p>Przepraszamy, ale logowanie jest chwilowo niedostępne.<br /><font color="red">Prosimy o kontakt z administratorem</font></p>');
setTimeout(function() {
infoAjax.fadeOut();
bgAjax.fadeOut();
}, 2500);
}
});
return false; // block load form action
});
var infoAjax = $('#infoAjax');
var bgAjax = $('#bgAjax');
$.ajax({
url: 'index.php',
dataType: 'JSON',
type: 'POST',
data: $('#form').serialize() + '&logIn=oo',
beforeSend: function(){
infoAjax.html('Trwa logowanie do systemu raportowania błędów<br /><img src="img/loading.gif">').css({'width':'400px',' position':'fixed','left':'50%'}).show();
bgAjax.show();
},
success: function(obj){
infoAjax.html(obj.info);
if(obj.check == 1){
setTimeout(function() {
location.replace(obj.link); //load to new page after logIn
}, 2500);
}else{
setTimeout(function() {
infoAjax.fadeOut();
bgAjax.fadeOut();
}, 2500);
}
},
error : function(){
infoAjax.html('<p>Przepraszamy, ale logowanie jest chwilowo niedostępne.<br /><font color="red">Prosimy o kontakt z administratorem</font></p>');
setTimeout(function() {
infoAjax.fadeOut();
bgAjax.fadeOut();
}, 2500);
}
});
return false; // block load form action
});
a teraz kodzik w pliku tpl
Kod
<div id="frameLogIn">
<img src="img/LogoSystemError.png" alt="System Raportowania Błędów" />
<div id="logIn">
<form id="form" action="index.php" method="post">
<input id="inputLogin" type="text" name="login" placeholder="Login" /><br />
<input id="inputPassword" type="password" name="password" placeholder="Hasło" /><br />
<input class="submit" id="logInUser" type="submit" value="Zaloguj" />
</form>
</div>
</div>
<div id="infoAjax"></div>
<div id="bgAjax"></div>
<img src="img/LogoSystemError.png" alt="System Raportowania Błędów" />
<div id="logIn">
<form id="form" action="index.php" method="post">
<input id="inputLogin" type="text" name="login" placeholder="Login" /><br />
<input id="inputPassword" type="password" name="password" placeholder="Hasło" /><br />
<input class="submit" id="logInUser" type="submit" value="Zaloguj" />
</form>
</div>
</div>
<div id="infoAjax"></div>
<div id="bgAjax"></div>
Nie mam już pojecia jak dane z php przekazać do jquery a następnie wyświetlić w "infoAjax"