Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

problem with jquery dialog

I have a partial view with a dropdown (with Paid and unpaid as options) and a button. I am loading this partial view using jquery load, when the user click Paid/Unpaid List link in the sub menu of a page.

When i select Paid in dropdown and click the button, it shows the list of paid customers in the jquery dialog and if i select Unpaid and click button, it shows unpaid customers in the jquery dialog.

I am writing the following code for the dialog:

 $('#customers').dialog({
            bgiframe: true,
            autoOpen: false,
            open: function(event, ui) {
                //populate table
                var p_option = $('#d_PaidUnPaid option:selected').val();
                if (p_option  == 'PAID') {
                    $("#customercontent").html('');
                    //$("#customercontent").load("/Customer/Paid");
                }
                else if (p_option  == 'UNPAID') {
                    $("#customercontent").html('');
                    //$("#customercontent").load("/Customer/Unpaid");
                }
            },
            close: function(event, ui) {
                //do nothing
            },
            height: 500,
            width: 550,
            modal: true
        });

For the first time, i am getting the list correctly in the jquery dialog, but when i click the Paid/Unpaid List link again and select Unpaid in the dropdown and click the button, it shows the previos loaded content in the jquery dialog.

What am i doing wrong here?

like image 238
Prasad Avatar asked Nov 03 '09 04:11

Prasad


2 Answers

Try adding no-caching option to jQuery AJAX. I had problems with the load() function (and IE) where cached results would always be shown. To change the setting for all jQuery AJAX requests do

$.ajaxSetup({cache: false});
like image 77
Marek Karbarz Avatar answered Oct 25 '22 07:10

Marek Karbarz


I hope Im not too late to come up with correct answer. I had the same problem and I solved it with following ajax settings.

open: function () {
      jQuery.ajaxSetup({
             cache: false
       });
       //populate table or do what you want...
}
like image 41
Eduard Avatar answered Oct 25 '22 07:10

Eduard