Question: I've researched several Q&As and articles on the subject and it seems somewhere I'm making a mistake in here. I've included this code in my $(document).ready javascript and loading this at the end of my index.html. Both IDs used are properly inserted on the HTML and looking through the Jquery.cookies documentation I'm not seeing what I've forgotten if anything. Would it be that I should load the cookie function at the beginning of my HTML?

HTML where the buttons switch to the proper language HTML file...

```
<div class="col-xs-12 col-sm-6 col-md-6"><br>
        <h1>Comment aimeriez vous être servi?</h1><a href="fr.html">
          <div id="set_fr_button" class="btn btn-primary btn-lg text-center">En Français</div></a>
      </div>
      <div class="col-xs-12 col-sm-6 col-md-6"><br>
        <h1>How would you liked to be served?</h1><a href="en.html">
          <div id="set_en_button" class="btn btn-primary btn-lg text-center">In English</div></a>
      </div>

```

JS file which includes the cookie code...

```
        $(function () {

    var url = 'mannydesigns.co';
    var en_page = 'en.html';
    var fr_page = 'fr.html';

    if ($.cookie('default_page') != null) {
        if (window.location.href != url + '/' + $.cookie('default_page')) {
            window.location.href = url + '/' + $.cookie('default_page');
        }
    }

    $('#set_en_button').click(function () {
        $.cookie('default_page', en_page, { expires: 999 });
    });

    $('#set_fr_button').click(function () {
        $.cookie('default_page', fr_page, { expires: 999 });
    });

    });

```

Answer: 
Use an interface. This way you can create your own callback whose methods can be called from onSuccess or onFailure.

```
public interface OnJSONResponseCallback {
    public void onJSONResponse(boolean success, JSONObject response);
}

public JSONObject getJSONObj(OnJSONResponseCallback callback) {
    ...
   @Override
   public void onSuccess(int i, Header[] headers, String response) {
       try {
           jObj = new JSONObject(response);
           callback.onJSONResponse(true, jObj);
       } catch (JSONException e) {
           Log.e("Exception", "JSONException " + e.toString());
       }
   }

   @Override
   public void onFailure(int statusCode, Header[] headers, String response, Throwable e) {
       try {
           jObj = new JSONObject(response);
           callback.onJSONResponse(false, jObj);
       } catch (JSONException e) {
           Log.e("Exception", "JSONException " + e.toString());
       }
   }
}

```

And to call it:

```
jsonParse.getJSONObj(new OnJSONResponseCallback(){
    @Override
    public void onJSONResponse(boolean success, JSONObject response){
       //do something with the JSON
    }
});

```
Use [retrofit](https://github.com/square/retrofit). It manages the http request very good and converts the json objects automatically to your Java objects. There is also a failure and success Callback. You can also decide whether the request is async or sync.