Support the ongoing development of Laravel.io →
IOC Views Blade

Hi,

Through ajax I am posting a value to a Controller, which I need get on the Modal Window on the VIEW Value changes every time Modal Window is triggered,

When i trigger the below

 {{ $fid = Session::get('field_id'); }}

Values doesnt get updated on the Modal, Shows the old (first) value only

<script>
        function CustomizeFields(type_id, field_id) {
            document.getElementById("type_id").value = type_id;
            document.getElementById("field_id").innerHTML  = field_id;

            jQuery.ajax({
                url: 'sessionfield',
                type: 'POST',
                data: {
                    txt: field_id
                },
                dataType : 'json',
                success: function(data, textStatus, xhr) {
                    console.log(data); // do with data e.g success message
                },
                error: function(xhr, textStatus, errorThrown) {
                    console.log(textStatus.reponseText);
                }
            });
        }
    </script>

Controller Function

 public function SessionField()
    {
        Session::put('field_id', $_POST['txt']);
        return Session::get('field_id');
    }
Last updated 3 years ago.
0

Are you using bootstrap by any chance? If so, have had this issue too. You need to reload the modal to be updated. I can't remeber the code of the top of my head that solved this. If you can't find it in google, let me know and I'll post it.

Sorry. Lame answer, but it might point you in the right direction.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

jaiimg jaiimg Joined 7 Jan 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.