1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Wait for JSON response inside a FOREACH

Discussion in 'jQuery' started by marcoVera, Sep 9, 2014.

  1. #1
    Hello,

    I have a doubt regarding how to show JSON reponse inside a FOREACH, what is happening is that FOREACH is not waiting the necesary time to get the response form JSON.

    I was searching some info. and I could find out that I can use queue or async.foreach but is not working for me (or maybe I'm not implementing it correctly)
    The issue maybe could be because I'm using JSON inside a function (function getTotal(idProcess,day)).

    
    function getProcesos(e){
      //I run here a JSON process
      $.each( jsonStr, function( key, val ) {
      var spanProceso = document.createElement('span');
      spanProceso.style.fontSize = setLimitSize;
      spanLunes.appendChild(document.createTextNode(" "+getTotal(val.ID,1)+"/"+val.Nombres));
      td2.appendChild(spanProceso );
      }
    function getTotal(idProcess,day){
      //I run here a JSON Process and return a result with the below variable.
      return getTotalUsers
      }
    
    Code (markup):
    As you can see I have inside the FOREACH a JSON call that is in a FUNCTION but I don't know how send the action to FOREACH to wait for the JSON response.

    Any Idea :S?

    Thanks in advance
     
    marcoVera, Sep 9, 2014 IP