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 7676885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:17:58+00:00 2026-05-31T17:17:58+00:00

I have a function that is to run through each row of a table,

  • 0

I have a function that is to run through each row of a table, grab the number from that cell, send that number to a url to fetch a json response, then print something based on that. I almost have it working but as it is now it is just dumping these all out at once, I want it to use something like .each to go through each row, do its stuff then move to the next. I am also working with jquery datatables. The script is like this :

$j('#imageCheck').click(function(){
    var cells = [];
    var rows = oTable.fnGetNodes();
    for( var i=0;i<rows.length;i++){
        grabsku = $j(rows[i]).find('td:eq(2)').text();
        imgreplace = $j(rows[i]).find('td:eq(2)');
        s7url = 'http://checkit.com/is/image/' + grabsku;       

        $j.ajax({
            type: 'GET',
            url: s7url,
            data: 'req=exists,json',
            dataType: 'jsonp',
            beforeSend:function(){
                imgreplace.html('checking ..');
            },
            success: function(){
                imgreplace.html(z);
            }
        });
    }
});

The response and everything works fine, my question is how to loop these one by one. So as in this example the imgreplace.html('checking ..'); happens simultaneously through every row in the table. I want it to just process that one row and after success move on to the next.

Update

To better explain why I am doing it this way, I agree it is unnatural, the data I grabbing from each cell helps form a unique url, s7url. Each of these returns a response like this from a server I have no control over:

s7jsonResponse(
{"catalogRecord.exists":"0"},"");

I then do something with knowing if true or false like this :

function jsonResponse(response){    
    x = response["record.exists"];  
    z = x == "0" ? "NO" : "YES";
}

I like scrappedcola’s solution but it led me to discover that the success is never being fired. I am not sure why that is. I can see in the inspector tab that there is a response like I pasted above. I tried to move the success into its own function, something like :

success: function(){ success(); } 

...

var success = function(){
    imgreplace.html(z);
    i++;
    handleImageCheck(i);    
}

but that didnt help..

Update 2

So I gave up trying to put the variables into success. Instead I will share with you my very ugly hack. On success of the error response, ick.

error: function(data, status){
        if (status = "parseerror") {
            imgreplace.html(z);
            i++;
            handleImageCheck(i);    
        }
    }

Update 3

If for some reason anybody cares, I found the solution for my other problem of success not firing. I needed to add jsonpCallback to the options and then process the response as a function in the succcess.

  • 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-31T17:18:00+00:00Added an answer on May 31, 2026 at 5:18 pm

    Something similar to this might work for you. Basically you should make 1 call to the image check function that makes the async call. Then upon success of the async call go to the next row.

    var i;  
      $j('#imageCheck').click(function(){ 
         i = 0;
         handleImageCheck(i);
      })
      var handleImageCheck = function(i){
         var cells = [];
         var rows = oTable.fnGetNodes();
         if($j(rows[i]).length)
         {     
        grabsku = $j(rows[i]).find('td:eq(2)').text();
        imgreplace = $j(rows[i]).find('td:eq(2)');
        s7url = 'http://checkit.com/is/image/' + grabsku;       
    
        $j.ajax({
          type: 'GET',
           url: s7url,
           data: 'req=exists,json',
           dataType: 'jsonp',
           beforeSend:function(){
              imgreplace.html('checking ..');
           },
           success: function(){
              imgreplace.html(z);
              i++;
              handleImageCheck(i);
           }
         });
        }
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looping through cells in a table row. each cell has a text box
gcc 4.4.2 c89 I have a function that has to run (config_relays). It make
I have a function that is side-effect free. I would like to run it
I have problem with fancybox. I want to write a function that will run
I have the following function that I only want to run inside <div id=imgWrapper>
In my Java code I have function that gets file from the client in
I have a function that is being called from different threads in the application.
So I have a script in place that needs to go through each P
I have a array.each function that calls a JSONP request for each item and
I have a function that keeps track of events that happen through out the

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.