Jquery Usage In Yii

How will I implement this code in Yii:




<script>

function suggest(inputString){

		if(inputString.length == 0) {

			$('#suggestions').fadeOut();

		} else {

		$('#lastname').addClass('load');

			$.post("autosuggest.php", {queryString: ""+inputString+""}, function(data){

				if(data.length >0) {

					$('#suggestions').fadeIn();

					$('#suggestionsList').html(data);

					$('#lastname').removeClass('load');

				}

			});

		}

	}


	function fill(thisValue) {

		$('#lastname').val(thisValue);

		setTimeout("$('#suggestions').fadeOut();", 600);

	}


</script>



I tried to put this code inside Yii registerscript but there’s an error of the action: “autosuggest.php”.

Try adding ‘autosuggest’ as an action rather in your controller and modify your access rules to give access to this function. Then replace


$.post("autosuggest.php", {queryString: 

by


$.post("index.php?r=yourcontroller/autosuggest", {queryString:......... 

if u are not using ajax or like something in that page, then simply put this code in that file… no need to register.