Hi, I'm having some difficulty getting my $.ajax to work correctly. The function is getting called however it is returning an empty string. I'm fairly new to using $.ajax so I appologize if this is easy. The program works when I run it w/o javascript it just loads a new page with the output. Thanks
Here is the .js
$(document).ready(function() {
$('#submit').click(function(){
var formdata = {
years: $('#years').val(),
rate: $('#rate').val(),
principle: $('#principle').val(),
periods: $('#periods').val(),
continuous: $('#continuous').val()
}
$.ajax({
url: "http://localhost:8888/CodeIgniter_1.7.2/index.php/timevalueshow/submit",
type: 'POST',
data: formdata,
success: function(data){
console.log(data);
$('#replace').replaceWith('<p>'+data+'</p>');
}
});
return false;
});
});
And here is the .php of the function being called.
function submit(){
$years = $this->input->post('years');
$rate = $this->input->post('rate');
$principle = $this->input->post('principle');
$periods = $this->input->post('periods');
$isCont = $this->input->post('continuous');
$params = array(
'years' => $years,
'rate' => $rate,
'principle' => $principle,
'periods' => $periods,
'isCont' => $isCont
);
$this->load->library('timevalue', $params);
return $this->timevalue->FVFactor();
}