Calling the ajax called URL works well without ajax eg. http://localhost/ci/controller/method/param_value. But using ajax it doesnt work. Following are the code segment, i have just started with JQuery+Ajax with CI.
Here is my controller:
<?php
class BaseController extends Controller{
public function BaseController(){
parent::Controller();
$this->load->helper('url');
}
function index(){
$this->load->view('header');
$this->load->view('body');
$this->load->view('footer');
}
function ajaxTest($testData=""){
//$this->load->view('ajaxtest',array('test_data'=>$testData));
echo 'Got It';
}
} ?>
Here is View
<?php
echo $test_data; ?>
Ajax Call Function
function testAjaxCall(){
$.post(
base_url+'basecontroller/ajaxtest/test-value',
function(responseData) {
$("#test-div").html(responseData);
}
);
}
Ajax Calling Page(button)
<div id="test-div"></div><input type="button" onclick="testAjaxCall()" name="ajax-test" value="Test Ajax" />
JS base_url declaration
<script type="text/javascript" src="<?php echo base_url();?>js/jquery.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>js/application-ajax-call.js"></script>
<script type="text/javascript">
/* to make ajax call easy */
base_url = '<?php echo base_url();?>';
</script>
Oh! interestingly, its working on IE8 but not FF. I am getting no clue.