i'm using ci built-in validation_errors() function in my login form. everything works fine and i can see true validation errors in my view. but when i echo validation errors into my js variable in the script to show it in the customized notifications, nothing shows. here is my code:
<?php if (isset($validation_error)){
echo $validation_error;} ?>
<script>
var text= "<?php echo $validation_error;?>";
</script>
<script src="<?php echo base_url();?>resources/js/assets/errore-not.js" type="text/javascript">
</script>
when i pass any php variables or strings in "text" variable of script, it shows the notification correctly. this is my notify code:
$(document).ready(function notification () {
$.notify({
icon: "notifications",
message: text
}, {
type: 'danger',
timer: 4000,
placement: {
from: 'top',
align: 'center'
}
});
});
How can I do this?
var text= $validation_error;which certainly won't work. Later you've edited the code to a working version.