Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > de.comp.lang.javascript > #4950

Re: not a function

Path csiph.com!feeder.erje.net!1.eu.feeder.erje.net!news.albasani.net!.POSTED!not-for-mail
From Jan Novak <repcom@gmail.com>
Newsgroups de.comp.lang.javascript
Subject Re: not a function
Date Wed, 2 May 2018 15:06:02 +0200
Organization albasani.net
Lines 77
Message-ID <pccd3q$j3$1@news.albasani.net> (permalink)
References <pbppha$jg2$1@news.albasani.net> <5377515.lOV4Wx5bFT@PointedEars.de> <pbrqbl$7tr$1@news.albasani.net> <539875bf-65c8-5053-b515-7a6491782f61@PointedEars.de>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 8bit
X-Trace news.albasani.net 0Ue22qoV1C94XdjgCMcfX9+5h9KxehvDb/t231xnnp6t6fiYr1wbqmxWajp2FIhDt4hprw4GjzbfLmvtDgDt2A==
NNTP-Posting-Date Wed, 2 May 2018 13:06:02 +0000 (UTC)
Injection-Info news.albasani.net; logging-data="XbRP3fTMJ0BZe9x7X4KyXxm38KQbcxPBEh7RDekjTg0EyfVGV+Wavg9mDkkAcNbQ4CeE0mo55ot8sietJbZQO17Cqn7nhz2vygv2VKlAVTyPFn4LcbzpEllhy1T3pwQj"; mail-complaints-to="abuse@albasani.net"
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0
In-Reply-To <539875bf-65c8-5053-b515-7a6491782f61@PointedEars.de>
Content-Language de-DE
Cancel-Lock sha1:Dtss9lnulnvUCfQUHSbXc0Y5Pbo=
Xref csiph.com de.comp.lang.javascript:4950

Show key headers only | View raw


Am 29.04.18 um 01:30 schrieb Thomas 'PointedEars' Lahn:
> Jan Novak wrote:
>> ich habe die Daten jetzt aus der Funktion ausgelagert:
>>
>> $.ajax({
>>        url: variable + '/include/fetch_doc_groups.php',
>>        async: false
>>      }).done(function(data) {
>>        dataNeu = JSON.parse(data);
>>      });
>>
>>
>> und hier nutze ich diese dann so:
>>
>> var initSelectableTree = function() {
>>     return $('#treeview-selectable').treeview({
>>       data: dataNeu,
>>
>> so funktioniert es.
> 
> Aber nur *zufällig*, mit *schneller* Netzverbindung und *lokalem*,
> *schnellen* Server.
> 
> Schau Dir bitte mein UML-Sequenzdiagramm noch einmal *genau* an:
> 
> Du hast lediglich das Problem *verlagert*, denn Deine globale Variable(?!)
> “dataNeu” ist nicht notwendigerweise gesetzt, wenn initSelectableTree()
> aufgerufen wird.  Denn der Server hat möglicherweise noch nicht geantwortet.
> 
> Richtig geht es so (wie Dir bereits vor einem Monat erklärt), und vor allem
> *ohne* globale Variablen:
> 
>    $.ajax({
>       url: … + '/include/fetch_doc_groups.php',
>       async: false
>    }).done(function (data) {
>      var dataNeu = JSON.parse(data);
> 
>      $('#treeview-selectable').treeview({
>         data: dataNeu,
>         …
>      });
>    });
> 
> Du hättest also auch einfach den Bootstrap-Code nehmen und
> 
>    $.getJSON(… + '/include/fetch_doc_groups.php',
>      function (data) {
>        $('#treeview-selectable').treeview({
>          data: data,
>          […]
>        });
>      });
> 
> schreiben können.  Allenfalls wäre noch
> 
>    (function () {
>      var treeView;
> 
>      $.getJSON(… + '/include/fetch_doc_groups.php',
>        function (data) {
>          treeView = $('#treeview-selectable').treeview({
>            data: data,
>            […]
>          });
>        });
> 
>       /* … treeView … */
>     }();
> 
> sinnvoll, wenn Du die Referenz auf den TreeView später noch brauchst.

wahooo.. das macht die ganze Sache etwas deutlicher.
Mal sehen, wie ich das weiter umsetzen werde.
Danke.

Jan

Back to de.comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

not a function Jan Novak <repcom@gmail.com> - 2018-04-25 13:41 +0200
  Re: not a function Sascha Hüdepohl <news@juenger-der-himmlischen-teekanne.de> - 2018-04-25 17:49 +0200
    Re: not a function Jan Novak <repcom@gmail.com> - 2018-04-26 07:39 +0200
  Re: not a function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-04-25 21:04 +0200
    Re: not a function Jan Novak <repcom@gmail.com> - 2018-04-26 07:55 +0200
      Re: not a function "Peter J. Holzer" <hjp-usenet3@hjp.at> - 2018-04-28 19:50 +0200
      Re: not a function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-04-29 01:14 +0200
    Re: not a function Jan Novak <repcom@gmail.com> - 2018-04-26 08:07 +0200
      Re: not a function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-04-29 01:30 +0200
        Re: not a function Jan Novak <repcom@gmail.com> - 2018-05-02 15:06 +0200
          Re: not a function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-05-05 01:00 +0100

csiph-web