Shinoy Babu
Shinoy Babu

Reputation: 1769

ReactJS How to call JSON data with out caching?

How can I make an AJAX call in ReactJS with out caching the json data?

this.serverRequest = $.get(this.props.source, function (result) {
        console.log("after serverRequest");           
    }.bind(this));

Upvotes: 0

Views: 69

Answers (1)

FunkyPeanut
FunkyPeanut

Reputation: 1182

It's a setting on jQuery Ajax:

Globally:

$(document).ready(function() {
      $.ajaxSetup({ cache: false });
});

or per request:

$.ajax({
    cache: false,
    url: "/path/to.json",
    dataType: "json",
    success: function(data) {
        ...
    }
});

Upvotes: 1

Related Questions