When I read the code, I was wondering if you plan to use the variable c anywhere else - if not, consider declaring it locally inside each scope and passing it as a parameter, i.e. elements(c) .
I also simplified this example a bit to simplify the analysis, because you only seem to have a problem with the variable. In the simplified snippet below, I added return c.one + ' ' + c.two; because it was not in your elements() function, and I added an declaration for the clicktag variable.
In addition, I noticed that console.log(elements()); called outside of the done and fail functions - if the request is running for a long time, there may be a race condition that calls c , not yet initialized when the log function is called. If your testing shows that it is, then place a log statement call inside each function ( done and fail ).
The code below - without delaying the request - seems to work fine (Internet Explorer and Chrome - I do not have Firefox installed to check it, maybe you can do it using the snippet below and tell me):
jQuery(function($) { var c = {}; var clicktag="https://stackoverflow.com/questions/47086470/javascript-variable-from-json-feed-object-not-recognized/47089907?noredirect="; $.when(SampleRequest(1), SampleRequest(2)).done(function(r1, r2) { c = { 'one': 'SUCCESS - DIE BESTEN', 'separator': ' ', 'two': 'ANGEBOTE', 'link': '1#', 'logo': 'img/fallback.png' }; elements(); }).fail(function() { c = { 'one': 'FAIL - DIE BESTEN', 'separator': ' ', 'two': 'ANGEBOTE', 'link': '1#', 'logo': 'img/fallback.png' }; elements(); })
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <span id='Storelogo'></span> <div id='interupterInner'></div> <div id='interupterInner'></div> <a id='clicktag'>click me</a>
Update: In response to the wintermute answer in the comments, the cause of the error is a more strict date parsing in Firefox.
I found a good link describing how to format the date correctly so that I can analyze it here . Essentially, this helps if you use a slash / , rather than a period . as a date separator.
However, I now tried it with the latest version of Firefox 57 , but I cannot repeat this behavior - the code fragment works fine, without any change on my PC.
source share