In this particular scenario, I am working on a message thread that is inside a modal. The objective is to display a message thread for a specific individual based on their reference number. However, I am encountering an issue in passing the reference number to my controller and retrieving it back to my blade (within the message thread). Below are the relevant sections of code:
Modal for Message Thread
<div id="threadmessage" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3>Message Thread</h3>
</div>
<div class="modal-body" style="height: 300px;" >
<div class="row" style=" margin-left: 30px; margin-bottom: 5px; left: 20px; width: 550px; height: 200px; overflow: auto;">
<div>
@foreach ($messageThread as $thread)
{!!$thread->message!!}
<br>
@endforeach
</div>
<br>
</div>
<div>
<br>
<div class="col-md-2">
<b> Message: </b><br>
</div>
<div class="col-md-10">
<textarea required=" " id="messageContent" style="resize: none;" class="form-control" rows="2"></textarea>
</div>
</div>
<br>
</div>
<div class="modal-footer">
<div>
<button type="button" id="btn-message" class="btn btn-default" data-dismiss="modal" style="background-color: #3c5fa6; color: white;">
Send <i class="fa fa-paper-plane-o ml-1"> </i>
</button>
</div>
</div>
</div>
</div>
</div>
Javasript Function for Displaying the Message Modal
$('#inquire_t tbody').on('click','#showMsg-btn',function(){
var flag = 6; // Approved
var refNumber = $(this).attr('value');
var cur_flag = $(this).attr('name');
var user = $("#username").html();
console.log(refNumber);
console.log(user);
$('#threadmessage').modal({"backdrop":"static"});
getMessage(refNumber, user);
});//btn-message
function getMessage(num, name){
var refNumber = num;
var username = name;
$.ajax({
url:'getAllMessage',
type: 'GET',
headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
data: refNumber+'refNumber'+username+'&username',
// dataType:'TEXT',
success: function(data){
}
})
}
Button to Trigger the Modal
"
Controller Logic for Retrieving Messages
public function getAllMessage(Request $request){
$refNumber = $request->get('refNumber');
$number = $refNumber;
$messageThread = DB::table('i_di_thread')->select('message')->where('refNumber', '=', $number)->get();
return view ('message', ['messageThread'=>$messageThread]);
}
Route Configuration
Route::get('showInquiries','HomeController@getAllMessage');
Route::get('getAllMessage','HomeController@getAllMessage');