开发者

JQuery Memory Cache in IE

开发者 https://www.devze.com 2023-02-14 01:49 出处:网络
I got a problem with JQuery in IE. The code works perfectly in firefox. I have a small form which add two details to db through ajax. This is my code

I got a problem with JQuery in IE. The code works perfectly in firefox. I have a small form which add two details to db through ajax. This is my code

$("#add").click(function(){
            $("#all_villa tr").remove();                                     
            var villa_name = $("#villa_name").val();
            var villa_desp = $("#villa_desp").val();
            var dataString = "villa_name=" + villa_name + "&villa_desp=" + villa_desp;
            $.ajax({
            type: "GET",
            url: "ajax_snippets/add_villa.php",
            data: dataString,
            success: function(data) { 
                    $("#all_villa tr").remove();
                    $("#msg").html(data);
                    $("#villa_name").val('');
                    $("#villa_desp").val('');
                    $("#all_villa").load("ajax_snippets/all_villa.php");
                }
            });             
            return false;
        }); 

After the details saved to db, a new line will be added to the table below to the form which contains the added details and two datepicker fields and two links to update and delete. When I test with IE, after the details added to the db, the lines will not be created and the existing update and delete links also not working. following are my update and delete codes

$("#all_villa .delete").click(function(){
        var k = this.id;
        var i = k.substr(3,4);
        var dataString = "id="+i;
        if(confirm("Do you really want to delete this villa?")){
            $.ajax({
            type: "GET",
    开发者_开发百科        url: "ajax_snippets/delete_villa.php",
            data: dataString,
            success: function(data) { 
                    $("#villa"+i).remove();
                    $("#msg").html(data);
                }
            }); 
        }else{}
            return false;
    });

    $("#all_villa .update").click(function(){
        var i = this.id;
        var from = $("#from_date"+i).val();
        var to = $("#to_date"+i).val();
        var available = $("#available"+i).val();
        if(from == ""){
            alert("From Date is Required"); 
            return false;
        }
        if(to == ""){
            alert("To Date is Required");   
            return false;
        }
        if(available == ""){
            alert("Availability is Required");
            return false;
        }
        var dataString = "from="+from+"&to="+to+"&id="+i+"&avlbl="+available;
            $.ajax({
            type: "GET",
            url: "ajax_snippets/update_villa.php",
            data: dataString,
            success: function(data) { 
                    $("#msg").html(data);
                    $("#villa_name").val('');
                    $("#villa_desp").val('');
                    $("#all_villa").load("ajax_snippets/all_villa.php");
                }
            });             
            return false;
    });

Can anybody tell me where did I made the wrong turn

Thanks


Add cache: false, to your ajax parameters


I added the following line and it works fine, hope this will help someone

$("#villa_tbl").load("ajaxsnippets/all_villa.php",{noncache: new Date().getTime()},function(){});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号