1

I have a page with button on it. When click the button jquery start running. It calls a function using ajax. I change the js file on project and try to see whats happening in localhost but js file is still runs old version before i changed and i can see on page source old version. why i can not change the file?

    $(this).click(function (e) {
        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: "test.aspx/function",
            data:  $(this).text(),
            dataType: 'Json',
            success: function (Result) {
                Result = Result.d;
                data = Result;      
            }
        });
    };

i want to change data but it still running as above data: $(this).parent().text(),

Aristos
  • 63,580
  • 14
  • 112
  • 146
Be Ta
  • 35
  • 8
  • 2
    Have you tried to reload the whole page again by pressing `Ctrl` + `F5` – Izzy Jan 02 '19 at 10:03
  • 2
    You need to make a full refresh: ctrl + F5 – Ricardo Alves Jan 02 '19 at 10:03
  • 1
    I did, even i restart computer and rebuild the project but i didnt change – Be Ta Jan 02 '19 at 10:08
  • Your file properly is still cashed by your browser. As mentioned above, if you refresh the site with `Ctrl + F5` you force your browser to download all files, even if they are already known to you / your browser. Often you can see these files responding with a HTTP 304 (not modified). – nilsK Jan 02 '19 at 10:11

1 Answers1

1

If you try to reload the test.aspx/function that is ajax called, you can open the developer tools (right click on page, click on inspect).

After the developer tools have been open, click on reload and keep that click until a menu opens. There click on "Hard Reload", or even the Empty Cache and Hard Reload

enter image description here

Other way is to use cache of jQuery ajax call for your tests.

And one other way is to disable the page cache for test.aspx/function on code behind. For example add that on your response.

    Response.Cache.SetExpires(DateTime.UtcNow.AddYears(-4));
    Response.Cache.SetValidUntilExpires(false);
Aristos
  • 63,580
  • 14
  • 112
  • 146