Click here to Skip to main content
15,880,427 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Firends


I am working with $.ajax and facing an cache issue, however I have mark the
JavaScript
cache:false
in my
JavaScript
$.ajax
request.

The server side code is working fine it returns the results as it should be. I tried to debug the code and found though the result is coming fine but
JavaScript
data.d
in ajax success method is returning / displaying the first executed result.
For example: In my 1st search for and server returns me 1 record, in 2nd search it return 70 records. I am successfully able to show the records in the
jqGrid
, but internally when I loop the records to search on
JavaScript
item 
variable in my code below it contains only 1 record instead of 70.

Below is my code:
JavaScript
$.ajaxSetup({
  // Disable caching of AJAX responses
  cache: false
});

$("#tblSearch").jqGrid("clearGridData", true).trigger("reloadGrid");
            var abc = Math.random();
            $.ajax({
                url: "abc.aspx/somemethod",
                data: JSON.stringify({ isActive: SIsActive, clientName: sName}),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                type: "POST",
                cache: false,
                success: function (Data) {
                    var item = undefined;
                    item = $.parseJSON(Data.d);

                 var items = undefined;

                 for (var i = 0; i < item.length; i++) {
                       var asu = item[i];
                       if (ClientID == asu.ClientID) {
                            // some code here
                            break;
                    }
               }

JavaScript
item.length
is not equals to 70.

After goggling this issue I found the browser IE, by default preserve the cache on the same request. So I tried to change the request by passing a random value to the url.
JavaScript
var abc = Math.random();


But it didn't work for me.

Any guess or success from your side please guide me.


Thanks
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900