john
john

Reputation: 11709

anti cache code to jquery getJson

I was asked this in an interview :

What is the proper syntax to add an anti-cache code to all jQuery getJson calls throughout a given project (without adding it to each getJson call). He asked me one liner code for this?

I am not sure how we can do this in one line?

Upvotes: 1

Views: 251

Answers (1)

michael
michael

Reputation: 758

You can use jQuery.ajaxSetup(options) to set default options that affect all subsequent AJAX calls, so you can do something like:

$.ajaxSetup({'cache': false});

jQuery docs

Upvotes: 2

Related Questions