Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1081541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:10:54+00:00 2026-05-16T22:10:54+00:00

i had asked a question about refering objects in a function that is inside

  • 0

i had asked a question about refering objects in a function that is inside jquery each function but that first function is defined before in a array.

In my question everything went ok (because i was testing with one element only), when i put 2 elements, it didn’t worked, it is calling the first always.

I think that is because ajax is assyncronous.

Can anyone give me a light?

The code is:

var $d=null;
var configs={
  general:{
    selector:'div.MicrodualAdGet',
    max_ads:6},
  logs:{
    selector:'div#MicrodualAdGet-debug'},
  connection:{
    type:'POST',
    url:'http://www.microdual.com/api/microdualgetad',
    cache:false,
    timeout:20000,
    dataType:'json',
    data:{
      adget_id:null,
      client_action:null},
    error:function(r,s,e){MicrodualAdGet_Log("Ajax-Error: "+s+"\n");},
    success: null
  }
};
function MicrodualAdGet_Log(msg){$(configs.logs.selector).append(msg);}
function MicrodualAdGet_View(d,s){
  if(! d) {
    MicrodualAdGet_Log("MicrodualAdGet-Error: Couldn't contact server correctly\n");
    $d.replaceWith("MicrodualAdGet Error: Couldn't contact server correctly");
  }else{
    if(d.hackattemp.status){
      MicrodualAdGet_Log("MicrodualAdGet-Hackattemp-Error: "+d.hackattemp.id+"\n");
      $d.replaceWith("MicrodualAdGet Hackattemp Error: "+d.hackattemp.id);
    }else{
      var content='';
      $d.css({
        display: 'block',
        position: 'relative',
        width: d.tamanhos[d.adpost.id_tamanho].width,
        height: d.tamanhos[d.adpost.id_tamanho].height,
        overflow: 'hidden',
        top: '0px',
        left: '0px',
        background: '#000000'
      })
      if(d.tipos[d.adpost.id_tipo].nome_tipo=='text') content=d.adpost.content;
      if(d.tipos[d.adpost.id_tipo].nome_tipo=='image') content='<a href="'+d.adpost.link+'" target="_blank"><img src="'+d.adpost.content+'" width="'+d.tamanhos[d.adpost.id_tamanho].width+'" height="'+d.tamanhos[d.adpost.id_tamanho].height+'" border="0" /></a>';
      if(content=='') content='MicrodualAdGet Error: Unable to determine ad type. Please contact our <a href="mailto:network@microdual.com">Network Administrator</a>';
      $d.replaceWith(content);
    }
  }
}



configs.connection.success = MicrodualAdGet_View;
configs.connection.data.client_action = "view";
$(configs.general.selector).each(function(){
  $d=$(this);
  configs.connection.data.adget_id=$(this).attr("rel");
  $.ajax(configs.connection);
});

Thanks in advance,
José Moreira

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T22:10:55+00:00Added an answer on May 16, 2026 at 10:10 pm

    Fixed,
    added async:false at config.connection array…

    var $d=null;
    var configs={
      general:{
        selector:'div.MicrodualAdGet',
        max_ads:6},
      logs:{
        selector:'div#MicrodualAdGet-debug'},
      connection:{
        type:'POST',
        url:'http://www.microdual.com/api/microdualgetad',
        cache:false,
        async:false,
        timeout:20000,
        dataType:'json',
        data:{
          adget_id:null,
          client_action:null},
        error:function(r,s,e){MicrodualAdGet_Log("Ajax-Error: "+s+"\n");},
        success: null
      }
    };
    function MicrodualAdGet_Log(msg){$(configs.logs.selector).append(msg);}
    function MicrodualAdGet_View(d,s){
      if(! d) {
        MicrodualAdGet_Log("MicrodualAdGet-Error: Couldn't contact server correctly\n");
        $d.replaceWith("MicrodualAdGet Error: Couldn't contact server correctly");
      }else{
        if(d.hackattemp.status){
          MicrodualAdGet_Log("MicrodualAdGet-Hackattemp-Error: "+d.hackattemp.id+"\n");
          $d.replaceWith("MicrodualAdGet Hackattemp Error: "+d.hackattemp.id);
        }else{
          var content='';
          $d.css({
            display: 'block',
            position: 'relative',
            width: d.tamanhos[d.adpost.id_tamanho].width,
            height: d.tamanhos[d.adpost.id_tamanho].height,
            overflow: 'hidden',
            top: '0px',
            left: '0px',
            background: '#000000'
          })
          if(d.tipos[d.adpost.id_tipo].nome_tipo=='text') content=d.adpost.content;
          if(d.tipos[d.adpost.id_tipo].nome_tipo=='image') content='<a href="'+d.adpost.link+'" target="_blank"><img src="'+d.adpost.content+'" width="'+d.tamanhos[d.adpost.id_tamanho].width+'" height="'+d.tamanhos[d.adpost.id_tamanho].height+'" border="0" /></a>';
          if(content=='') content='MicrodualAdGet Error: Unable to determine ad type. Please contact our <a href="mailto:network@microdual.com">Network Administrator</a>';
          $d.replaceWith(content);
        }
      }
    }
    
    
    
    configs.connection.success = MicrodualAdGet_View;
    configs.connection.data.client_action = "view";
    $(configs.general.selector).each(function(){
      $d=$(this);
      configs.connection.data.adget_id=$(this).attr("rel");
      $.ajax(configs.connection);
    });
    

    Thank you all…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had asked a question about parsing a file in ruby. I accepted an
I asked a question about this previously but my database structure has changed, and
I had the same question as was asked in this thread , i.e. I
I had telephone interview question yesterday. The interviewer asked me if I had faced
I recenty asked a question about parallel programming algorithms which was closed quite fast
I had asked this question in a much more long-winded way a few days
Quite recently, I asked a question about debugging a seg fault: What are some
I didn't see any similar questions asked on this topic, and I had to
I had this answer on another post I asked: I believe the VS designer
Had an interesting discussion with some colleagues about the best scheduling strategies for realtime

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.