In my web , there is \"message\" button in every user profile , so when any user click on \"message \" button , it should to move him to \"message\" page with ajax .
1-
Instead of creating AJAX request, you can submit user details to controller. Where view is getting loaded.
$("#startMessage").click(function(){
var user_id = $("#user_id").val();
/*
* AJAX request won't work here, because you had sent user_id data to controller "Message/index" using AJAX,
* then in it's success method you are again redirecting to page controller "Message/index", here user_id details are not present
* Instead will just create a form and submit that form to controller "Message/index", so that variable user_id will available in "Message/index"
* Once form submitted to controller Message/index, view "front/Message_View" was already getting loaded their as per existing code
*/
var formHTML = '<form name="frmUserData" action="<?php echo base_url('Message/index')?>" method="post">'+
'<input type="hidden" name="user_id" value="'+ user_id +'">'+
'</form>';
var formObj = $('.main-footer').append(formHTML).find("[name='frmUserData']");
$(formObj).submit();
});