0

so i have a website made in ASP.NET that uses JS to generate some DOM elements after getting settings from the users account.

problem is that after i sign out and log in with a different user name i get the generated elements from the previous user and i don't know why. the code that generates the elements is as follows:

$.ajax({
    url: '@Url.Content("~")' + 'Ticket/GetTvrtke',
    async: false,
    success: function (data) {
        document.getElementById("header_tvrtka_holder").innerHTML = data;
    }
});

and a little afterward its is used as such: var tvrtke = document.getElementById("header_tvrtka_holder").innerHTML.split(", ");

$.each(tvrtke, function (index, value) {
    $("#KlijentMultiSelect").append("<option value=\"" + value + "\" id=\"" + index + "\" >" + value + "</option>");
});

now when i log off and sign in as a different user the ajax code above doesn't trigger the getTvrtke URL that gets the settings wich generate the elements and i don't know why.

2
  • Can you try setting cache to false with $.ajaxSetup({cache: false})? I doubt this should impact in case of different user profiles. Commented Jan 28, 2013 at 8:34
  • @ryadavilli thank you, that seemed to do the trick. post it as an answer so that i can vote it up :) Commented Jan 28, 2013 at 8:37

1 Answer 1

1

Ajax by default caches the response of the calls. YOu can set it to false so that there is a fresh request every single time by using the below at the top of your application.

$.ajaxSetup({cache: false});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.