Chtml::ajax() Doesn't Work

I need to check the user’s login and give some notice to the user if his password is wrong .etc.

I cannot use model to help do this because of some reasons.So I write the ajax myself. I do that like this.

views/user/login.php




   <form action = '<?php echo Yii::app()->createUrl('User/Login');?>' name = 'signup' method = 'POST'>

	Email <input type= 'text' id= 'email' name = 'email'><br>

	Password <input type= 'password' id= 'password' name= 'password'><br>

	<span id= 'error_info'></span> <!--display the error here -->

	<input type= 'submit' value='submit' onclick='checkValue()'>

   </form>


	

   <script language= 'javascript'>

	function checkValue(){

		var email = document.getElementById('email').value;

		var password = document.getElementById('password').value;

		<?php

			echo CHtml::ajax(

				array(

					"url" => CController::createUrl("User/Login"),

					"data" => "js:{email : email, password : password}",

					"type"=>"POST",

					//'error'=>"js:function(){alert('error')}",

					"success"=>"js:function(data){alert(data)}",

				)

			);

		?>


	}

   </script>

   

UserController




   class UserController extends Controller

   {

        public function actionLogin(){

	      if(isset($_POST['email'])){

		  echo 'test notice';

              }

           $this->render('login');

        }

    }

   

When I submit the form. The ‘test notice’ that should be in <span id=‘error_info’></span> appears at the upper left corner,and nothing has alerted. If I uncomment //‘error’=>“js:function(){alert(‘error’)}” in the view, it will alert error and disappear quickly,then the notice ‘test notice’ will appear at the upper left corner.

And if I write param success like this,it will alert ‘ok’.So there maybe something wrong when the client accept the response from controller.Where is the error?I cann’t find it myself.Is there some grammar error or something?


"success"=>"js:alert('ok')"

I have write the original ajax code that works fine without yii,however, it still doesn’t work in Yii.




   <script language = 'javascript'>

	function checkValue(){

		 $.ajax({

    	        type: "POST",            

    	        url: "http://127.0.0.1/project/index.php?r=User/Login",   

    	        dataType: "text",  

    	        success: function(data){  

		        	 alert(data);

                }

    	    });

	}

   </script>

   

So I doubt if there is any problem with the yii jquery file,so I add the newest jquery file in the view,but it doesn’t work.


<script src='http://127.0.0.1/project/js/jquery.js'></script>

Why and how to solve it?

Thank you for your patient to read that.Please help~~ Thank you very much!It have annoyed me serveral days.

H-E-L-P!!!