Hi, i have this View code:
[html]
<script>
$(document).ready(function(){
$('#ajaxform').submit(function(){
var formData = $(this).serialize();
alert(formData);
return false;
});
});
</script>
<form id="ajaxform" name="ajaxform" method="post">
<input type="text" id="name" name="name">
<input type="text" id="family" name="family">
<input type="submit" id="submit" value="Submit">
</form>
[/html]
in above code, event handler on the submit dont work. but when add a CHtml::ajaxlink (or like it)that works. for example the submit event handler in followning code work.
[html]
<script>
$(document).ready(function(){
$('#ajaxform').submit(function(){
var formData = $(this).serialize();
alert(formData);
return false;
});
});
</script>
<form id="ajaxform" name="ajaxform" method="post">
<input type="text" id="name" name="name">
<input type="text" id="family" name="family">
<input type="submit" id="submit" value="Submit">
</form>
<!-- The following line dont related to above code, its just for enabling JQuery's function -->
<?php echo CHtml::ajaxLink('fetch-ajax-data', array('Ajax'), array('success'=>'js:function(data){$("#ajax-data").val(data)}')); ?>
[/html]
What is the reason?