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?...