jQuery - 如何使用不同的步骤进行响应?

I want to have an ajaxed form and when a user clicks submit it will submit the form values to a php file nothing fancy here and to that point anything is clear to me.

Now I want to have several responses from the server to shop in the response div.

For example the form is for writing a post and then my php file will post that post to 5 different forums and I want to show in the result exactly what it is doing like

Posting to forum 1... then clear that and show Posting to forum 2...

I want to show what the script is currently doing live in the jquery output div and my question is how to do that? Please tell me the code requirements in jquery as well as the ones in PHP.

Thanks in advance for your help

Here is a function that should accomplish this for you:

//'step' indicates the current iteration of the posting loop, and 'limit' tells it after how many iterations to stop. If you want to post to 5 of 5 forums, set 'step' to 1 and 'limit' to 5.

function submitSteps(step, limit)
{
    if (step <= limit)
    {
    $.ajax({
        url: 'http://example.com',
        data: 'postTo='+step,
        beforeSend: function()
        {
             if ($('#notice p:last').html().indexOf('problem') > -1)
             {
                  $('#notice p:last').remove();
             }
             $('#notice').append('<p>Posting to forum '+step+'...</p>');   
        },
        success: function()
        {
             $('#notice p:last').remove();
             $('#notice').append('<p>Post to forum '+step+' complete!</p>');
             window.setTimeout('submitSteps(step+1, limit)', 1000);   
        },
        error: function()
        {
             $('#notice p:last').remove();
             $('#notice').append('<p>There was a problem posting to forum '+step+'.</p>');
             window.setTimeout('submitSteps(step, limit)', 1000);    
        }
    }
}