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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:23:02+00:00 2026-06-13T22:23:02+00:00

The application has to request a web service by $.ajax , but the times

  • 0

The application has to request a web service by $.ajax, but the times would be multiple, and it depends on the user. Since it’s dynamic, it seems that $.when can’t work for it.

Here is the code:

var increase=0;
    var test_use_upload_file_name= t2_image_path+ increase;
var soap_add_new_story_image=
    '<?xml version="1.0" encoding="utf-8"?>' +
    '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' + 
            'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '+
            'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'+
                '<soap:Body>'+
                    '<AddNewStoryImage xmlns="http://x.x.x.x/StoryForMac/">'+
                        '<StoryID>'+story_id+'</StoryID>'+
                        '<UserName>'+User_Name+'</UserName>'+
                        '<DragNumber>'+Drag_Number+'</DragNumber>'+
                        '<ImagePath>'+test_use_upload_file_name+'</ImagePath>'+
                    '</AddNewStoryImage>'+
                '</soap:Body>'+
            '</soap:Envelope>';   


//multiple ajax request
var start= 0;
for(;start< **USER_Decide**;start++)
{
    $.ajax({
        type: "POST",
        url: webServiceAddNewStoryImgUrl,
        contentType: "text/xml",
        dataType: "xml",
        data: soap_add_new_story_image,     
        success: process_add_new_img_Success,
        error: process_add_new_img_Error        
    }); 
    increase++;
    test_use_upload_file_name= t2_image_path+ increase; 
}

Since I don’t know how much pic the user will draw, I have to update the file name each time(increase++).

Please any kind of suggestion~ Thanks!

UPDATE:
Sorry for my poor expression. This code WON”T WORK. My problem is similar to this Please take a look. But the difference is that I don’t know how many times I have to call the ajax request, because the user will determine it.
Thus, I can’t use the method $.when provided here.
Is it clear?…

  • 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-06-13T22:23:03+00:00Added an answer on June 13, 2026 at 10:23 pm

    Check this, one one possible methods to acheive your goal http://jsfiddle.net/oceog/mNegP/

    var object = {
        a: {
            id: 'aaa',
            text: 'bbb'
        },
        b: {
            id: 'ccc',
            text: 'cccc'
        }
    };
    var json = JSON.stringify(object);
    console.log("JSON:", json);
    
    //that will run callback when counter is zero
    var check_success = function(num, callback) {
        console.log("one done",num,"left");
        if (num <=0) {
            callback();
        }
    }
    
    var checkloop = function() {
            var done=0;
          var num=10;// (decide by user);
    //this will be called only if all requests done
    var run_onlast=function() {
        console.log("last done");
        };
        //at this point we know how many ajax we would run in row
        for (var i = 0; i <= num; i++) {
            console.log("start",i);
            $.post('/echo/json/', {
            //just for sample, random delays
                json: json,delay: Math.round(Math.random()*4)
            },  "json").success(function(data) {
            //run our check function provide it with our last function and our callback
                check_success(num,run_onlast)
            }).error(function(data) {
    
                console.log({
                    error: data.responseText
                });
            }).complete(function() {
            //always reduce, even if error
                num--;
            });
        }
            done=1;
    }
        
        checkloop();
    ​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've created a graphing application that calls a web service. The user can zoom
I am calling an ASP.net application that has an exposed JSON web service interface.
I'm developing a web application that has to support lots of simultaneous requests, and
I was in a ASP.NET application has heavy traffic of AJAX requests. Once a
My application has one activity which starts two services but does not bind them.
My application has multiple SQLite tables(around 20 with different fields). This I have created
The application has been put in iCloud since the beginning, so I have the
My application has two layouts A and B. In A a user chooses some
My Application has the following structure: myproject (primary Silverlight project) myproject.Web (website for the
Our application has a service layer and a DAO layer, written as Spring beans.

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.