Can a JS string variable be used in Twig? I've came to the situation where I need to use JS variable string and use it in Twig's variable. 

The plan is built on the Guest entries and Ajax form submission. On successful Ajax form submission I'm calling for entry's keys (especially id key) and using these keys to set a cookie names. Those cookie names should be used on next page to get into the entry that just got submitted. Can it be achieved?
As Twig is rendered server side before passed to a browser for JS execution I found out that it can't be done except FOSsRoutingBundle which allows you to expose your routing in your JavaScript code. I don't know if that would be a great idea.

Anyway. I found workaround solution that seems to be working for me.

Here is the Ajax post action with simple window redirection.

// Send it to the server
$.post('/', data, function(response, textStatus, jqXHR) {

  if (response.success) {

    // Request for entry ID key string to be used in HTTP redirect link
    var entryId = response.id

    // HTTP redirect
    window.location.replace("{{ siteUrl }}" + entryId + "/someUri");

    } else {
    // response.error
  }

});


Don't forget Craft's routing!