I'm new in web development. How can i load my php file that contains html in order to change the span content. Im using codeigniter by the way.
I always get an error.
here is my js file
$(document).ready(init);
function init(){
$('#home').click(doAjax);
}
function doAjax(){
$.ajax({
data:{
'n':1
},
type: 'get',
success: ajaxSuccess,
error: ajaxError,
url: 'http://localhost/index.php/main/ajax'
});
function ajaxSuccess(data, textStatus){
alert("sucess");
$('#main-span').load(data);
}
function ajaxError(data, textStatus){
alert("error");
$('#main-span').html('error');
}
}
controller
public function ajax(){
$input = $this->input->get('n');
$input = '/application/views/student_main.php';
echo $input;
}
maincontent - this is where i want the span to update
<div class="container-fluid">
<div class="row">
<div class="col-sm-3 col-md-2 sidebar" id ="nav-sidebar">
<?php include('/application/views/navigation.php');?>
</div>
<span id="main-span">
<?php include('/application/views/evaluation.php');?>
</span>
</div>
</div>
thanks in advance for those who can answer my problem.