After trying some solutions from this and many other questions I wasn\'t able to get what is exact problem in my code. My code
$(document).ready(function() {
$.ajax({
URL: "= base_url()?>/controller name/function name",
type: 'POST',
data: {school_code:school_code,class_name:class_name},
contentType: "application/json; charset=utf-8",
success: function(res)
{
console.log(res);
}
});
Actually the real problem in this case is URL. if the URL is not set properly then function will not call and Ajax will return the same page content in response. so please check your URL and set it like above.