0

I am using laravel 4.2 for my project. I have used following code in the head section of my view to update the availability of courses for a given semester. My view outputs the result in several pages showing course code, title, semester, lecturer and availability in several table columns. I want to let the user to select an option from a drop down menu to change the availability (offered or Not Offered) and when an option is selected by the user, I want to reload the content of the page by showing the selected option (offered or Not Offered) in one of the table columns.

$(document).ready(function() {
  $('.change_offStatus').on('change', function() {
   var status = $(this).val(); //name is the selected offering status option
      alert(status);
   if (status == "Change") {
    }
   else {
      var code = this.name; //this is the course code
      alert(code);
    $.ajax({
    url: "{{ URL::Route('ChangeOfferingStatus')}}",
    data: {
      new_status: status,
      c_code: code
    },
    dataType: 'json',
    type: 'POST',
    success: function(res) {
      if (res == '1') {
        alert("Error in Changing the Offering Status!");
      }
      else {
        document.location.reload();
      }
     }
    });
   }
 });

});

In the content section, I have the following code to have a drop down menu for the user to select an option (offered or Not Offered) and once an option is chosen by the user, I want to reload the page showing the selected option. However, the page successfully reloads only in the first page by showing the selected option and not in the subsequent pages. I searched extensively for an answer but the none of them have helped to to change the above code to make it reload the page to display the selected option in pages other than the first page.

    <td>
      @if($offering_status['status']==1)
      Offered
    @else
      Not Offered
    @endif
   <br>
     <select name="{{$course_detail->code}}"  id='change_offStatus' 
         class="change_offStatus" type="text">
       <option>Change</option>
      @if($offering_status['status']==1)
       echo "<option>Not Offered</option>";
      @else
       echo "<option>Offered</option>";
      @endif          
    </select>
   </td>

How to change the above code to make it work with all the pages?

tharaka
  • 11
  • 2
  • 1
    What does _“does not work”_ mean, precisely? Please, [edit] your question and include your _desired_ results, your _actual_ results, including all _errors_, and demonstrate _your research and your attempts_ and explain what precisely didn’t work. Use the [browser console (dev tools)](https://webmasters.stackexchange.com/q/8525) (hit `F12`) and read any errors. Also see [Why is “Can someone help me?” not an actual question?](https://meta.stackoverflow.com/q/284236/4642212). – Sebastian Simon Jul 27 '18 at 13:29
  • 1
    How can you alert after you reload? – epascarello Jul 27 '18 at 13:30

0 Answers0