我正在嘗試修改Ion auth以使用ajax,因爲我的登錄表單是固定大小,我想在提交表單時提供錯誤的數據時提醒錯誤消息。如何在alertbox中顯示codeigniter表單驗證消息
的消息從控制器這樣的返回:
$this->session->set_flashdata('message', $this->ion_auth->messages());
,並在這樣的觀點拾起:
<div id="infoMessage"><?php echo $message;?></div>
我想如下顯示它們:
<?php if((isset($message))&&($message!='')){
echo '<script> alert("'.$message.'"); </script>';
}
?>
這不工作,警報沒有顯示,我已經刪除了消息分隔符,但是這並沒有沒有幫助。我唯一的想法就是它必須是與方式笨正在打造我的javascript中間的新行,因爲它是走出這樣的:
<script>
alert('The Identity field is required.
The Password field is required.');
</script>
我怎樣才能擺脫這種換行,並更換它在某種程度上不會打破我的js?
你正在使用jQuery或香草JavaScript? – doktorgradus
都在我的處置,所以jQuery解決方案將工作 – WebweaverD