[eluser]Piekarz[/eluser]
Hi, I try to use jQuery in my code. I got the html select/option list like this:
Code:
<select class="emaillist">
<option value="emails"></option>
<!-- list of email adresses... -->
</select>
I create jQuery function like this:
Code:
$("select.emaillist").change(function() {
$.ajax({
type: "POST",
url: "http://localhost/mgr/index.php/welcome/post_ajax",
dataType: "json",
data: "email="+$(this).text(),
cache:false,
success:
function(data){
$("div.leftecho").text(data);
}
});
return false;
});
and in my welcome controller I put this code:
Code:
public function post_ajax(){
if(isset($_POST['email'])){
$this->session->set_userdata('selectedemail',$_POST['email']);
return true;
}
}
Could anyone say my why this code doesn't work? When I add this code to my jQuery function:
Code:
statusCode: {
404: function() {
alert("page not found");
}
}
It always shows alert message, why ajax can't verify my url well? Is it the problem?