I am trying to adapt Ion auth to work with ajax, because my login form is a fixed size, i want to alert the error messages when a form is submitted with incorrect data.
The messages are returned from the controller like this:
$this->session->set_flashdata('message', $this->ion_auth->messages());
and picked up in the view like this:
<div id="infoMessage"><?php echo $message;?></div>
I am trying to display them as follows:
<?php if((isset($message))&&($message!='')){
echo '<script> alert("'.$message.'"); </script>';
}
?>
This isn’t working, the alert is not being displayed, I have removed the message delimiters but this didn’t help. My only thought is it must be something to do with the way codeigniter is creating a new line in the middle of my javascript as it is coming out like this:
<script>
alert('The Identity field is required.
The Password field is required.');
</script>
How can I get rid of this newline and replace it in a way that wont break my js?
Try